Ejemplo n.º 1
0
        public bool Equals(SimpleDayTime dTime)
        {
            // Check for null.
            if (dTime == null)
            {
                return(false);
            }

            // Check for ReferenceEquals if this is a reference type.
            if (ReferenceEquals(this, dTime))
            {
                return(true);
            }

            // Possibly check for equivalent hash codes.
            if (this.GetHashCode() != dTime.GetHashCode())
            {
                return(false);
            }

            // Check base.Equals if base overrides Equals().
            System.Diagnostics.Debug.Assert(base.GetType() != typeof(object));

            if (!base.Equals(dTime))
            {
                return(false);
            }

            // Compare identifying fields for equality.
            return(this.weekDay.Equals(dTime.weekDay) && this.hour.Equals(dTime.hour) && this.minute.Equals(dTime.minute) && this.second.Equals(dTime.second));
        }
Ejemplo n.º 2
0
        public int CompareTo(object obj)
        {
            if (!(obj is SimpleDayTime))
            {
                throw new ArgumentException("object is not a SimpleDayTime");
            }

            SimpleDayTime st2 = obj as SimpleDayTime;

            // Start off assuming a result of equality (zero).
            int result = 0;

            // Work our way through testing weekday, hour, minute, second.
            if (this.weekDay > st2.weekDay)
            {
                result = 1;
            }
            else if (this.weekDay < st2.weekDay)
            {
                result = -1;
            }
            else if (this.hour > st2.hour)
            {
                result = 1;
            }
            else if (this.hour < st2.hour)
            {
                result = -1;
            }
            else if (this.minute > st2.minute)
            {
                result = 1;
            }
            else if (this.minute < st2.minute)
            {
                result = -1;
            }
            else if (this.second > st2.second)
            {
                result = 1;
            }
            else if (this.second < st2.second)
            {
                result = -1;
            }

            return(result);
        }