I want to write an extension method for the List class that takes an object and adds it to the front instead of the back. Extension methods really confuse me. Can someone help me out with this?
myList.AddToFront(T object);
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<T>already has anInsertmethod that accepts the index you wish to insert the object. In this case, it is 0. Do you really intend to reinvent that wheel?If you did, you’d do it like this
But again, you’re not gaining anything you do not already have.