Is there a built in method in C# to get the max index in a List ?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
No, there isn’t a built-in method. You can always use
For a List, you are guaranteed that the elements will be in the range 0..Count-1, so you can create an extension method:
Off course, these lines will return -1 when the list has 0 elements, which might be a problem.