C# new关键字的用法

  1. new 运算符:用于创建对象和调用构造函数,返回的是对象的内存地址,存放在线程栈上;
  2. new 修饰符:在用作修饰符时,new 关键字可以显式隐藏从基类继承的成员;
  3. new 约束:用于在泛型声明中约束可能用作类型参数的参数的类型;
 1 class FClass{
 2     public string field1 = "输出基类字段";
 3     public void Print1(){
 4         Console.WriteLine("输出基类方法");
 5     }       
 6 }
 7 class CClass : FClass{
 8     new public string field1 = "屏蔽基类字段";
 9     new public void Print1(){
10         Console.WriteLine("屏蔽基类方法");
11     }
12 }
原文地址:https://www.cnblogs.com/My-Sun-Shine/p/13513839.html