類別繼承範例

#C#

Posted by Phyxsius on 2023-09-14

using System.Security.Cryptography.X509Certificates;

internal class Program
{
    private static void Main(string[] args)
    {
        Console.WriteLine("Hello, World!");

        B b = new B("x",100);
        b.show();

        C c = new C("y",200);
        c.show();
    }
}

class A
{
    public A(string a, int b)
    {

    }

    public void show()
    {
        Console.WriteLine("A  Class");
    }
}

class B:A
{
    public B(string x, int y) : base(x,y)
    {

    }
}

class C:B
{
    public C(string x, int y):base(x,y)
    {

    }

    public new void show()
    {
        Console.WriteLine("C  Class");
    }
}

#C#







Related Posts

七天打造自己的 Google Map 應用入門 - Day00

七天打造自己的 Google Map 應用入門 - Day00

2. SpringBoot使用jms整合IBM MQ

2. SpringBoot使用jms整合IBM MQ

讀書筆記-版本控制使用Git: 檔案管理、索引、送交

讀書筆記-版本控制使用Git: 檔案管理、索引、送交


Comments