重载 Sort, ==, !=

   class Items:IComparable
    {
        public string Item { get; set; }
        public string File { get; set; }
        public string IsScored { get; set; }
        public string Weight { get; set; }

        public int CompareTo(object obj)
        {
            if (obj is Items)
            {
                Items second = obj as Items;
                if (this.Item.CompareTo(second.Item) == 1)
                    return 1;
                else
                    return -1;
            }
            else
                return -1;
        }

        
        public static bool operator !=(Items first, Items second)
        {
            bool pass = true;
            if ((first.Item != second.Item) || (first.File != second.File) || (first.IsScored != second.IsScored) || (first.Weight != second.Weight))
                pass = true;
            else
                pass = false;
            return pass;
        }

        public static bool operator ==(Items first, Items second)
        {
            bool pass = true;
            if ((first.Item == second.Item) && (first.File == second.File) && (first.IsScored == second.IsScored) && (first.Weight == second.Weight))
                pass = true;
            else
                pass = false;
            return pass;

        }
    }
原文地址:https://www.cnblogs.com/qixue/p/2966330.html