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

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


i want to get value that has index=2

[edit]Code block added - OriginalGriff[/edit]
Updated 22-Aug-13 5:56am
[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

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