Question

I have one generic list , from which I want to get those items only which are starting between some alphabets.

Supoose I have listitems like ABC,DEF,Zebra,Important,Check,Jump

From this I want to get listitem which starts from alphabet between A to C

This should return ABC,Check only..

Thanking in advance.

Was it helpful?

Solution

List stringlist= new List() {"ABC","BCD", "CDE","DEF","EFG","PQR","IJK","QRS","XYZ"};

List temp=stringlist.FindAll(s=>Enumerable.Range(65,3).Contains(s.toUpper()[0]));

change the range as per your requirement.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top