Reputation: 2281
i need to find out a string from collection of strings using its sub string. This sub string must be in starting.
Upvotes: 1
Views: 6454
Reputation: 1224
you can do something like this,
List<string> collection = new List<string>();
collection.Add("example sample");
collection.Add("sample");
collection.Add("example");
var varSubstring = collection.Where(x => x.IndexOf("sample")==0).ToList();
foreach (var vartemp in varSubstring)
{
}
Upvotes: 2