I have a List
and i need to take a sublist out of this list. Is there any methods of List available for this in .NET 3.5?
Use the Where clause from LINQ:
List
In the statements above "p" is the object that is in the list. So if you used a data object, i.e.:
public class Client
{
public string Name { get; set; }
}
then your linq would look like this:
List x = new List();
x.Add(new Client() { Name = "A" });
x.Add(new Client() { Name = "B" });
x.Add(new Client() { Name = "C" });
x.Add(new Client() { Name = "D" });
x.Add(new Client() { Name = "B" });
var z = x.Where(p => p.Name == "A");
z = x.Where(p => p.Name == "B");