public void TestVirtuals() { var t = new testVirtual(); var p = new Program(); var virtualVar1 = t.Foo(true); StringAssert.AreEqualIgnoringCase("i do something you might not want me to.", virtualVar1); var virtualVar2 = p.Foo(true); StringAssert.AreEqualIgnoringCase("now it does what you wait it to.", virtualVar2); var virtualVar3 = p.Foo(false); StringAssert.AreEqualIgnoringCase("i do something you might not want me to.", virtualVar3); }
static void InterfacesTester() { #region sample var p = new Program(); p.MethodToImplement(); p.ParentInterfaceMethod(); var br = p.wow(); Console.WriteLine(br.ToString()); // call second main from polynomys/driver Driver.MainPolynoms(); // use animal interface var dogs = new List <Dog> { new Dog("Somedog") }; var puppy = new Dog("littleOne"); dogs.Add(puppy); dogs.Add(new Dog("aDog")); dogs.Sort(); foreach (var dog in dogs) { Console.WriteLine(dog.Describe()); } puppy.Name = "newDog"; foreach (var dog in dogs) { Console.WriteLine(dog.Describe()); } var comparable = new Dog("newname"); var comparable2 = new Dog("newname"); var a = comparable2.CompareTo(comparable); var b = a == 1 ? true : false; Console.WriteLine("Puppy a and b are same? " + b.ToString()); var c = Dog.CompareNames(comparable, comparable2); Console.WriteLine("Puppy a and b are same? " + c.ToString()); p.IzJedinice(); var a1 = ((Idva)p).IzJedinice(); Console.WriteLine(a1.ToString()); ((Ijedan)p).SameName(); (p as Idva).SameName(); var t = new testVirtual(); t.Foo(); p.Foo(); #endregion }