I have List<T>
and I want to find two random name from that List<T>
starting with some condition from List using .NET 2.0.
I know its very easy with LINQ but I am stuck with 2.0
I am wondering if I can do something like this
List<foo> list = new List<foo>();
List<foo> newlist = new List<foo>();
Random r = new Random();
list.Add(new foo("1"));
list.Add(new foo("A91"));
list.Add(new foo("A01"));
list.Add(new foo("A71"));
list.Add(new foo("B02"));
list.Add(new foo("B2"));
list.Add(new foo("B03"));
list.Add(new foo("23"));
list.Add(new foo("24"));
string[] searchList = { "A", "B", "C",};
foreach (string name in searchList)
{
List<foo> templist = list.FindAll(delegate (foo f)
{
List<foo> templist1 = f.Name.StartsWith(name);
{
if(templist1.Count>0)
{
while (templist.Count != 0)
{
??.Add(templist1[r.Next(templist1.Count)]);
}
retrun ??
}
}
});
}