Related, but not Duplicate (it's a completely different language, PHP not C#):
How to create multi-dimensional array from a list?
How would I go about converting a list of 'Tuple's to string[,]?
This is part of a web crawler, but i'm messing with conversions of lists and arrays just out of curiosity. Here's the method.
private string[,] getimages(string url)
{
List<Tuple<string, string>> images = new List<Tuple<string, string>>();
string raw = client.DownloadString(url);
while (raw.Contains("<a class=\"title \" href"))
{
raw = raw.Substring(raw.IndexOf("<a class=\"title \" href"));
String link = raw.Substring(24, raw.IndexOf(">", 24) - 26);
int startname = raw.IndexOf(">", 24) + 1;
int endname = raw.IndexOf("</a> ");
String name = raw.Substring(startname, endname - startname);
images.Add(new Tuple<string, string>(name, link));
raw = raw.Substring(endname);
}
}
I want to return 'images', but converted to a multidimensional array.