static void Main(string[] args)
        {
            MyTime t1 = new MyTime {
                Hours = 1, Mins = 20, Secs = 30
            };
            MyTime t2 = new MyTime {
                Hours = 10, Mins = 20, Secs = 30
            };

            Console.WriteLine(t1.Equals(t2));
            Console.WriteLine(t1);  // t1.ToString()
        }
Esempio n. 2
0
        public static void Main()
        {
            MyTime t1 = new MyTime {
                Hours = 10, Mins = 20, Secs = 30
            };
            MyTime t2 = new MyTime {
                Hours = 10, Mins = 20, Secs = 30
            };

            int n = t1;                  // uses Conversion Operator

            Console.WriteLine(t1 == t2); // MyTime.operator==(t1,t2)
        }
Esempio n. 3
0
        static void Main(string[] args)
        {
            var n = new MyTime {
                Hours = 10, Mins = 20, Secs = 30
            };
            var person = new { Name = "Abc", Age = 30 };

            Console.WriteLine(person.Name);

            dynamic d = "Abc";

            Console.WriteLine(d.Length);

            String name = "C#";

            Console.WriteLine($"Name = {name}");
        }
        public override bool Equals(object obj)
        {
            MyTime other = obj as MyTime; // Downcasting - object to MyTime

            return(this.TotalSeconds == other.TotalSeconds);
        }