user642378
user642378

Reputation: 167

c# collections List class

Greetings!

I am using List class.I will define my code below.

List<c1> lis = new List<c1>();

where c1 is class. I want to find index of particular item in List.say in list i have, 10,20,30,40 inside List.In this how i find the index of 30.Please help me to get a solution.

Thank You Regards Jennie

Upvotes: 0

Views: 160

Answers (3)

Euphoric
Euphoric

Reputation: 12849

c1 c = new c1(); should be INSIDE the loop.

Actualy, what is your code supposed to represent? Are you aware you have Array inside a list. So in your case, you end up with List with 4 items of same instance of single object, that has array of 4 items with strings "0","1","2","3". You should fix this first before you ask your question again.

Upvotes: 0

KCH
KCH

Reputation: 2844

Maybe this is what are you looking for? List.IndexOf Method (T)

Upvotes: 1

CodingBarfield
CodingBarfield

Reputation: 3398

Use:

lis.IndexOf(value)

That should return the first index of the requested value.

Upvotes: 0

Related Questions