Solarion
Honorary Master
- Joined
- Nov 14, 2012
- Messages
- 28,050
- Reaction score
- 17,804
I am trying to create a method that can take in any list<T> then insert this row into that list, and return it. This is using a Student class for example:
I will then use that list to bind to a combobox. The reason for this is that at any time I need to populate a combobox I will always have the following as the first item: "Please Select"
This is about as far as I've gotten. The "YourDerived" is where the steam train left the track and ended up down into a ravine and disappeared under water in a plume of white steam and a trail of destroyed trees in it's wake.
Please if you guys have any suggestions I would very much appreciate it!
Edit: This is not work related but something I am hoping to use in future.
students.Insert(0, new Student() { Name = "Please Select" });
I will then use that list to bind to a combobox. The reason for this is that at any time I need to populate a combobox I will always have the following as the first item: "Please Select"
This is about as far as I've gotten. The "YourDerived" is where the steam train left the track and ended up down into a ravine and disappeared under water in a plume of white steam and a trail of destroyed trees in it's wake.
C#:
public List<T> AddItem<T>(List<T> collection)
{
collection.Insert(0, new YourDerived { Id = 0, Name = "Please Select" });
return collection;
}
Please if you guys have any suggestions I would very much appreciate it!
Edit: This is not work related but something I am hoping to use in future.