I have 5 datas in my list.
MyList
So i want to know , how can i get selected Id\'s Row Number ?
var MyProductId= 135;
var Se
You can get it directly the element by Index if your list has implemented indexer. You can find that How to implement Indexer.
Another way could be as described in Here.
The above link shows it like:
COPIED From Above link:
Person agedTwenty = myList.Where( x => return x.Age == 20; ).Single();
int index = myList.IndexOf(agedTwenty);
or alternatively
int index = myList.Where( x => return x.Age == 20; ).Select( x =>
myList.IndexOf(x)).Single();
In case there can be more than one result you'd do this:
IEnumerable allAgedTwenty = myList.Where( x => return x.Age == 20; );
IEnumerable indices = allAgedTwenty.Select( x => myList.IndexOf(x) );
The first case will get you only one int and the second case will leave you with a list of ints.