Let\'s say I have a web page that currently accepts a single ID value via a url parameter:
http://example.com/mypage.aspx?ID=1234
I want to change it to acce
Something like this might work:
public static IList GetIdListFromString(string idList)
{
string[] values = idList.Split(',');
List ids = new List(values.Length);
foreach (string s in values)
{
int i;
if (int.TryParse(s, out i))
{
ids.Add(i);
}
}
return ids;
}
Which would then be used:
string intString = "1234,4321,6789";
IList list = GetIdListFromString(intString);
foreach (int i in list)
{
Console.WriteLine(i);
}