Exemple #1
0
        private static void TestInheritance()
        {
            BaseFoo foo = new BaseFoo();
            BaseFoo foo1 = new BaseFoo("Fooyao");
            SubFoo soo = new SubFoo();
            SubFoo soo1 = new SubFoo("SubADubDub");
            BaseFoo foo2 = new SubFoo("Wally");

            Console.WriteLine("foo: {0}", foo);
            Console.WriteLine("foo1: {0}", foo1);
            Console.WriteLine("soo: {0}", soo);
            Console.WriteLine("soo1: {0}", soo1);
            Console.WriteLine("foo2: {0}", foo2);
        }
 public FooIdentifier(SubFoo subFoo, string propertyC)
 {
     this.InnerSubFoo = subFoo
                        this.PropertyC = propertyC;
 }
Exemple #3
0
        private static void TestCollectionsInheritance()
        {
            BaseFoo foo = new BaseFoo();
            SubFoo subFoo = new SubFoo();
            List<BaseFoo> baseList = new List<BaseFoo>();
            List<SubFoo> subList = new List<SubFoo>();
            BaseFooCollection baseCollection = new BaseFooCollection();
            SubFooCollection subCollection = new SubFooCollection();

            Console.WriteLine("subFoo is{0} a sub class of BaseFoo", subFoo is BaseFoo ? string.Empty : " not");
            Console.WriteLine("subList is{0} a subtype of BaseFoo List", subList is List<BaseFoo> ? string.Empty : " not");
            Console.WriteLine("subCollection is{0} a subtype of BaseFooCollection", subCollection is BaseFooCollection ? string.Empty : " not");
            Console.WriteLine("subCollection is{0} an implementation of ICollection<BaseFoo>", subCollection is ICollection<BaseFoo> ? string.Empty : " not");
        }