Try Fail Learn Grow

Lessons in Technology Project Leadership

Skip to content
  • Home
  • About this site
  • Dev How-To Archive
Search

List

How to Sort a Generic List of Objects

January 2, 2014 / Jim McMullen / Leave a comment

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

How to Split a String into a Generic List Rather Than an Array

May 29, 2013 / Jim McMullen / Leave a comment

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:

How to Convert a Generic List to a Comma-Delimited List

March 25, 2013March 27, 2013 / Jim McMullen / Leave a comment

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

How to Find the Index of an Object in a List

February 1, 2013 / Jim McMullen / Leave a comment

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:

How to Find the Index of a String in a List

October 17, 2011October 17, 2011 / Jim McMullen / Leave a comment

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.

This Site

  • About this site
  • Dev How-To Archive

Search

Categories

  • Best Practices (5)
  • Career Management (2)
  • Just My Opinion (1)
  • Programming How-To Archive (28)
  • Reviews (1)
  • Tips & Tricks (1)

Meta

  • Create account
  • Log in
  • Entries feed
  • Comments feed
  • WordPress.com

Connect with Me

  • LinkedIn
Create a free website or blog at WordPress.com.
Privacy & Cookies: This site uses cookies. By continuing to use this website, you agree to their use.
To find out more, including how to control cookies, see here: Cookie Policy
  • Subscribe Subscribed
    • Try Fail Learn Grow
    • Already have a WordPress.com account? Log in now.
    • Try Fail Learn Grow
    • Subscribe Subscribed
    • Sign up
    • Log in
    • Report this content
    • View site in Reader
    • Manage subscriptions
    • Collapse this bar