Beispiel #1
0
        public static void IExampleNullableType()
        {
            DerivedExample ins1 = new DerivedExample();
            StructExample  ins2 = new StructExample();
            DerivedExample ins3 = default(DerivedExample);

            var m6m1 = new NullableIExampleValue <DerivedExample?>(ins1);
            var m6m2 = new NullableIExampleValue <StructExample>(ins2);
            // warning
            var m6m3 = new NullableIExampleValue <IExample?>(ins3);
        }
Beispiel #2
0
        public static void IExampleNonNullableType()
        {
            var ins1 = new DerivedExample();
            var ins2 = new StructExample();
            var ins3 = new DerivedClass();

            var m6m1 = new NonNullableIExampleValue <DerivedExample>(ins1);
            var m6m2 = new NonNullableIExampleValue <StructExample>(ins2);
            var m6m3 = new NonNullableIExampleValue <IExample>(ins1);
            var m6m4 = new NonNullableIExampleValue <IExample>(ins2);
            // Error
            //var m6m4 = new NonNullableIExampleValue<DerivedClass>(ins3);
        }
Beispiel #3
0
        private static void DeriveFromIExampleType()
        {
            var ins1 = new StructExample();
            var ins2 = new DerivedExample();
            var ins3 = new BaseClass();
            var ins4 = new AppenderExample();
            var ins5 = new AppenderExample2(122);

            var m8m1 = new DerivedTypeInMethodValue <IExample>();

            m8m1.Add(ins1);
            m8m1.Add(ins2);
            // error
            //m8m1.Add(ins3);

            var m8m2 = new DerivedTypeInValue <IAppender <IExample>, string, IExample>("123")
            {
                DerivedData = ins2,
                Appender    = ins4
            };
        }