zoukankan      html  css  js  c++  java
  • 19._7泛型继承之泛型类继承普通类

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Threading.Tasks;
    
    namespace _19._7泛型继承之泛型类继承普通类
    {
        abstract class genClass<T>
        {
            protected T field;
            public virtual T property
            {
                get { return field; }
            }
    
            public genClass(int index) { }
            public genClass(T t) { field = t; }
    
            public abstract void method(T t);
        }
    
        class ordinaryClass : genClass<int>
        {
            public override int property
            {
                get
                {
                    return base.property;
                }
            
            }
            public ordinaryClass(int t) : base(t) { }
            public override void method(int t)
            {
                Console.WriteLine("property属性值为:{0}",t);
            }
        }
        class Program
        {
            static void Main(string[] args)
            {
                int val = 1000;
    
                ordinaryClass oc = new ordinaryClass(val);
                oc.method(val);
                Console.WriteLine("泛型类继承普通类演示成功");
                Console.Read();
            }
        }
    }
  • 相关阅读:
    CSU 1122
    CSU 1256
    CSU 1240
    HDU 1874
    CSU 1004
    Problem F CodeForces 16E
    Problem E CodeForces 237C
    Problem C FZU 1901
    12-30
    2016-12-29
  • 原文地址:https://www.cnblogs.com/zqyo2000z/p/5785618.html
Copyright © 2011-2022 走看看