C#继承

关于继承--和子承父业一样一样滴,----你继承了谁谁的东西也归你所有了

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            b b1 = new b();//实例化 b

            b.a2();

            Console.ReadKey();
        }
    }
    class a
    {
        public void a1()
        {
            Console.Write("a1");
        }
        public static void a2()
        {
            Console.Write("a2");
        }
    }
    class b : a//b 类继承了 a
    { 
        
    }
}
class b : a//b 类继承了 a
    { 
        
    }
就相当于
class b
    {
     public void a1()
        {
            Console.Write("a1");
        }
        public static void a2()
        {
            Console.Write("a2");
        }
}



原文地址:https://www.cnblogs.com/yangfengwu/p/5864208.html