Created
November 22, 2013 15:19
-
-
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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