c# - How to use OrderBy to sort a custom object ascending by Date -


i have collection of custom object follows:

public struct record {     public string caller { get; set; }     public datetime started { get; set; }     public string dialed { get; set; }     public decimal duration { get; set; }     public decimal cost { get; set; }     public string location { get; set; }     public switch switch { get; set; } }  public static list<record> records { get; set; } 

using linq, how can sort records in ascending order using value stored in record.started ?

just use orderby method:

records.orderby(record => record.started) 

or:

from r in records order r.started select r 

Comments

Popular posts from this blog

toolbar - How to add link to user registration inside toobar in admin joomla 3 custom component -

linux - disk space limitation when creating war file -

How to provide Authorization & Authentication using Asp.net, C#? -