The Situation You are trying to sort a Generic List of Objects based on a property of the Objects. A Solution There are two easy options for sorting a Generic List populated with Objects: in place and sorting to a new List. Use Linq. "In Place" sorting of an existing List (the code below only … Continue reading How to Sort a Generic List of Objects
The Situation You want to split a string, but the C# split() function returns a string array. You want a List<string> instead. A Solution If you are using .Net 3.5 or later, use Linq extensions:
The Situation: You have a List<string> and need to convert it to a comma-delimited list (for display or storage). A Solution: This is a great example of how C# has improved over the years. I found this solution in this StackOverflow discussion and don't want to lose it, so I am copying it here for … Continue reading How to Convert a Generic List to a Comma-Delimited List
The Situation You are trying to find out if an object exists in a List object. A Solution Use Linq. The example below looks for a User object in a List<User> by searching for the UserName:
The Situation You are trying to find out if a string exists in a List object. A Solution You could use a Find with a predicate, or try the simple method below.