Skip to content

Instantly share code, notes, and snippets.

@csharpforevermore
Created November 22, 2013 15:19
Show Gist options
  • Save csharpforevermore/7601553 to your computer and use it in GitHub Desktop.
Save csharpforevermore/7601553 to your computer and use it in GitHub Desktop.
Get a property of a collection (e.g. Id property of MyClass) as a string CSV
class MyClass
{
public int Id { get; set; }
public string FirstName { get; set; }
public string LastName { get; set; }
//...
}
public static string GetPropertyIdAsList()
{
const string seperator = ", ";
var list = new List<MyClass>();
// ...
return String.Join(seperator, list.Select(i => i.Id).ToList()); ;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment