Click here to Skip to main content
15,938,218 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i have this list

C#
List<string> phoneList=new List<string>();


phonelist.add("Gress"):
phonelist.add("Ali"):
phonelist.add("Ehab"):
phonelist.add("Solo"):
phonelist.add("Yanee"):




i want to get value that has index=2


[edit]Code block added - OriginalGriff[/edit]
Posted
Updated 22-Aug-13 5:56am
v2
Comments
[no name] 22-Aug-13 11:53am    
And is there something stopping you from using an index to get this value?
Rabee3-F1.787545 22-Aug-13 11:57am    
no i tried this string name=phonelist[2];
but it does not work
[no name] 22-Aug-13 13:02pm    
Yes it does work. You would need to show us reproducible code that demonstrates a case where you say it does not work.
Trak4Net 22-Aug-13 12:03pm    
Are you getting no value or are you not getting the value you expected? From your example code phonelist[2] should equal Ehab. If you are getting no value then I would re-evaluate your variable for phonelist becase "phoneList" and "phonelist" are different variables (notice the casing) which I assumed was a typo here, but could be a typo in your code also.

1 solution

C#
string strValue = phoneList[2];
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900