I have been searching around the internet for a few questions I have on the List<T> class with no success.
1. how do you edit the last item in your list
2. how do you edit a specific items value, every time i do it says you cannot edit a return value. i simply do this list[item].x = 2;
3. how do you iterate through a list, with out using foreach because i need to edit the iterating variable
4. this is part of the 1st question and the 3rd but what is a lists equivalent to an arrays length property.

thank you for any help you provide

Recommended Answers

All 3 Replies

1) list[list.Count-1]
2) Is x a public property or is it a method? More info on your implementation, please.
3) for (int i = 0; i < list.Count; i++)
4) I think you know by now.

double post

nvm on number 2, i was using a struct and changed to a class and it worked. I am a C++ programmer learning C#. Ty though that really helped.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.