Sort list of custom objects

CodeKeep C# Feed Maggio 23rd, 2008

Description: How to sort a list of custom objects

Link: http://www.codekeep.net/snippets/f9ad5647-8d1d-45ae-bd20-3e5ec077ae43.aspx

    public abstract class MyObjects: IComparable<Actions>
    {
        public Int64 sortnumber { get; set; }

        /// <summary>
        /// Compare two objects
        /// </summary>
        /// <param name="other">The objects to be compared with.</param>
        /// <returns>
        /// A 32-Bit Signed Integer that states the relative sortorder of the two objects
        /// </returns>
        public int CompareTo(Actions other)
        {
            return this.sortnumber.CompareTo(other.sortnumber);
        }
    }

  • .NET
1 Star2 Stars3 Stars4 Stars5 Stars (No Ratings Yet)
Loading ... Loading ...

Comments are closed.

Trackback URI |