pandiyaraj k

pandiyaraj k

  • NA
  • 73
  • 8.2k

Sort a custom list - list of struct

Jul 21 2012 11:03 AM
I have struct "StructEventlist " and listed that in List "LstEventList "

 public struct StructEventlist 
        {
            public string EntryType;
            public string EventSource;
            public string EventCategory;
            public DateTime EventDate;
            public int EventID;
            public string Message;
        }
        public List<StructEventlist> LstEventList = new List<StructEventlist>();


Assigned values for struct here

for (i = ev.Entries.Count - 1; i >= 0; i--)
                {
                    EventLogEntry CurrentEntry = ev.Entries[i];
  StructEventlist Evlist = new StructEventlist();
                        Evlist.EntryType = CurrentEntry.EntryType.ToString();
                        Evlist.EventSource = CurrentEntry.Source;
                        Evlist.EventCategory = CurrentEntry.Category;
                        Evlist.EventDate = CurrentEntry.TimeGenerated;
                        Evlist.EventID = CurrentEntry.EventID;
                        Evlist.Message = CurrentEntry.Message;
}

Then added to list
                        LstEventList.Add(Evlist);

Now i want to sort the list "LstEventList" by "Evlist.EventDate".

Please help me!




Answers (1)