public static void ExerciseTypes() { MyInt a1; a1.Value = 44; Int64 i64 = Convert.ToInt64(a1); bool b1 = Convert.ToBoolean(a1); MyIntStruct a; int b; a = 45; b = (int)a; Console.WriteLine("a = {0} , b ={1}", a.ToString(), b.ToString()); Test1 t1 = new Test2(); Console.WriteLine(t1.ToString()); Console.WriteLine(t1.foobar().ToString()); //interface ValChange v = new ValChange(); v.Date = DateTime.Now; v.Value = 5.4432; Console.WriteLine("ValChange v =:" + v.ToString()); Test3 t3 = new Test3(); IComparable t3i = t3; Console.WriteLine("T3 IComparable interface:{0}", t3i.CompareTo(new object())); Test2 t2 = new Test2(); Console.WriteLine("T2 IComparable interface v1:{0}", t2.CompareTo(new Test2())); IComparable t2i = t2; Console.WriteLine("T2 IComparable interface v2:{0}", t2i.CompareTo(new Test2())); TestEnum te = TestEnum.Frau; Console.WriteLine("Test enum is equal to Mau:{0}", te == TestEnum.Mau); Gen1 <Test3, ValChange> g1 = new Gen1 <Test3, ValChange>(t3, v); Console.WriteLine("Generic class g1 to string:" + g1.ToString()); }
public override bool Equals(object obj) { try { ValChange v = (ValChange)obj; if (v._date == this._date && v._val == this._val) { return(true); } else { return(false); } } catch { return(false); } }