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

namespace InheritingTest
{
    class BeInheritingedOne
    {
        public static string StrOne="I am from BeInheritinged one";

        public static void ShowInheritingOne()
        {
            Console.WriteLine(StrOne);
            Console.ReadLine();
        }
    }

       class InhertingFromFirst : BeInheritingedOne
    {
        public static new string StrOne = "I am from BeInheritingedOne but i used new";

        public static new void ShowInheritingOne()
        {
            Console.WriteLine(StrOne);
            Console.ReadLine();
        }

//覆盖了继承的属性和方法
    }

    class Program
    {


        static void Main(string[] args)
        {
            BeInheritingedOne.ShowInheritingOne();
            InhertingFromFirst.ShowInheritingOne();
        }
    }
}

 

c#  类 覆盖

 

c#  类 覆盖

相关文章:

  • 2022-01-06
  • 2021-12-14
  • 2022-12-23
  • 2022-12-23
  • 2021-09-22
  • 2022-12-23
  • 2022-02-24
  • 2021-08-10
猜你喜欢
  • 2021-08-07
  • 2022-12-23
  • 2022-12-23
  • 2021-10-29
  • 2021-06-12
  • 2022-02-01
相关资源
相似解决方案