Friday, November 6, 2015

Generate a comma separated string from an IEnumerable object

string.join(",", Contacts.Select(x=>x.Name); //Name is a property of an object(Contact) in the list of Contacts

Wednesday, November 4, 2015

Simple yet effective way to find if IEnumerable has elements or not

bool IsEmpty(IEnumerable en)
{
    foreach(var c in en) { return false; }
    return true;
}