Exemplo n.º 1
0
        static void Main(string[] args)
        {
            StringDisperser stringDisperser = new StringDisperser("gosho", "pesho", "tanio");

            foreach (var ch in stringDisperser)
            {
                Console.Write(ch + " ");
            }
            Console.WriteLine();
        }
        public override bool Equals(object obj)
        {
            StringDisperser secondDisperser = obj as StringDisperser;

            if (secondDisperser == null)
            {
                return(false);
            }
            if (!(secondDisperser.Strings.Equals(this.Strings)))
            {
                return(false);
            }
            return(true);
        }
        public int CompareTo(StringDisperser otherDisperser)
        {
            string strings      = string.Join("", this.Strings);
            string otherStrings = string.Join("", otherDisperser.Strings);

            if (string.Compare(strings, otherStrings) > 0)
            {
                return(1);
            }
            else if (string.Compare(strings, otherStrings) == 0)
            {
                return(0);
            }
            return(-1);
        }