M
Magus
I'm about to bash my head against the wall. I can't seam to figure out when calling List.Add(string[]) it seems to change every value in the List.
My code as follows:
private List<string[]> ReadUpdateHash(string URL)
{
string[] values = new string[2];
List<string[]> hashes = new List<string[]>();
using (XmlReader reader = XmlReader.Create(WebRequest.Create(URL).GetResponse().GetResponseStream()))
{
while (reader.Read())
{
if (reader.IsStartElement()) // Is start element
{
if (!reader.IsEmptyElement)
{
switch (reader.Name)
{
case "Name":
Array.Clear(values, 0, 2); // Clear if first element
if (reader.Read()) { values[0] = reader.Value; }
break;
case "Hash":
if (reader.Read()) { values[1] = reader.Value; }
hashes.Add(values);
break;
}
}
}
}
}
return hashes;
}
And I'm using the following to call it:
// Get the updated hashes stored online
List<string[]> onlineHashes = new List<string[]>();
onlineHashes = ReadUpdateHash("http://www.gamersjudgement.com/OCTGN/Hash.XML");
The values that List returns all contain the same values as the last array added.
My code as follows:
private List<string[]> ReadUpdateHash(string URL)
{
string[] values = new string[2];
List<string[]> hashes = new List<string[]>();
using (XmlReader reader = XmlReader.Create(WebRequest.Create(URL).GetResponse().GetResponseStream()))
{
while (reader.Read())
{
if (reader.IsStartElement()) // Is start element
{
if (!reader.IsEmptyElement)
{
switch (reader.Name)
{
case "Name":
Array.Clear(values, 0, 2); // Clear if first element
if (reader.Read()) { values[0] = reader.Value; }
break;
case "Hash":
if (reader.Read()) { values[1] = reader.Value; }
hashes.Add(values);
break;
}
}
}
}
}
return hashes;
}
And I'm using the following to call it:
// Get the updated hashes stored online
List<string[]> onlineHashes = new List<string[]>();
onlineHashes = ReadUpdateHash("http://www.gamersjudgement.com/OCTGN/Hash.XML");
The values that List returns all contain the same values as the last array added.