static void Main(string[] args) { BaseClass baseClass = new DerivedClass(); baseClass.DoWork(); Console.WriteLine("\nAdHoc полиморфизм"); // AdHoc полиморфизм //dynamic dynamic[] arrayClass = { new OneClass(), new TwoClass(), new ThreeClass() }; foreach (var item in arrayClass) { item.Method(); } //Interface IInterface MyClass = new MyOneClass(); MyClass.Method(); MyClass = new MyTwoClass(); MyClass.Method(); MyClass = new MyThreeClass(); MyClass.Method(); Console.ReadKey(); }
public void Equal_WhenVariableIsClassWithImplicitOperator_WhenCastToCorrectType_Succeeds() { int one = new MyOneClass(); var classQuery = _realm.All <AllTypesObject>().Where(o => o.Int32Property == one).ToArray(); Assert.That(classQuery.Length, Is.EqualTo(1)); Assert.That(classQuery[0].Int32Property, Is.EqualTo(1)); }
public void Equal_WhenVariableIsClassWithImplicitOperator_Fails() { var one = new MyOneClass(); Assert.Throws <NotSupportedException>(() => _realm.All <AllTypesObject>().Where(o => o.Int32Property == one).ToArray()); }