Wednesday, October 27, 2010

How to use Lamda Expression in list.FindIndex() c# to find the index of a charater in chracter array?.

The below code will help you to find the index of a charatecte from the list or array


string[] alphabet = {"A", "B", "C", "D","E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O","P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z","1","2","3","4","5","6","7","8","9","0"};

int index= alphabet.ToList().FindIndex(s => s == "G");.

X will contain the index of the character G in the list or array.

You can find more infomration regarding lamda expression from the below link

http://msdn.microsoft.com/en-us/library/bb397687.aspx

No comments:

Post a Comment