.

generic list inline sorting using delegates

 an example of how to use an inline sort function with a delegate to define the sort process 

public static List<Container.Speciality> getSpecialties()
{
    Kingsweb2DataAccess.Kingsweb2DataClassesDataContext newdb =
        new Kingsweb2DataAccess.Kingsweb2DataClassesDataContext();

    List<Container.Speciality> res =
        new List<Kingsweb2DataAccess.Container.Speciality>();
    var x = from m in newdb.specialities select m;
    foreach (Kingsweb2DataAccess.speciality xx in x)
    {
        res.Add(new Kingsweb2DataAccess.Container.Speciality(xx.Id));
    }

    res.Sort(delegate(Kingsweb2DataAccess.Container.Speciality a,
        Kingsweb2DataAccess.Container.Speciality b)
            { return a.Specialityname.CompareTo(b.Specialityname); });

    return res;
}

What's your thoughts on this?

*

Protected by WP Anti Spam