I am using List.ElementAt(0) and List.ElementAt(1) to get the elements I need. How ever I don’t want to hardcode 0 and 1 is there any other way in C#
I am using List.ElementAt(0) and List.ElementAt(1) to get the elements I need. How ever
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.
List.First() will work. However, you really shouldn’t be using ElementAt if you can help it — it’s slow. And since you’re using a list you can indeed help it. Use the indexer instead (List[0], List[1]).