I’m retuning a list of months from a function.
I’m looking to see if there’s an elegant solution to adding 3 elements to the beginning of that list.
Thanks for your suggestions.
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.
You can use
List.Insert()for that, it takes the index at which you want to add the new item, i.e. to add at the beginning:Also to add multiple items at the same time you can use
List.InsertRange()which takes anIEnumerableas second parameter: