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
Post a Comment