I have an arraylist called ‘pri1’, I want this array list to be available to other methods:
void downloader_OpenReadCompleted(object sender, OpenReadCompletedEventArgs e)
{
if (e.Error == null)
{
Stream responseStream = e.Result;
StreamReader responseReader = new StreamReader(responseStream);
string response = responseReader.ReadToEnd();
string[] split1 = Regex.Split(response, "},{");
List<string> pri1 = new List<string>(split1);
pri1.RemoveAt(0);
string last = pri1[pri1.Count() - 1];
pri1.Remove(last);
List<string> str = pri1;
}
}
so a suggestion to me was to save it to a class variable which i did:
private List<string> str = new List<string>();
unfortunately the elements of ‘pri1’ did not successfully pass on to ‘str’:
void AddPrimaryMarkerGraphics(object sender, getPrimaryListCompletedEventArgs e)
{
foreach (string item in str)
{
So I was wondering where in these 3 steps did I go wrong?
My guess is that you’ve still declared a new local variable within your
downloader_OpenReadCompletedinstead of assigning to the existing variable: