详细介绍C#中new的几种用法


当前第2页 返回上一页

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

using System;

 public class MyBaseC

 {

 public class MyClass

 {

 public int x = 200;

 public int y;

 }

 }

 public class MyDerivedC : MyBaseC

 {

 new public class MyClass // nested type hiding the base type members

 {

 public int x = 100;

 public int y;

 public int z;

 }

 public static void Main()

{

 // Creating object from the overlapping class:

 MyClass S1 = new MyClass();

 // Creating object from the hidden class:

MyBaseC.MyClass S2 = new MyBaseC.MyClass();

 Console.WriteLine(S1.x);

 Console.WriteLine(S2.x);

 }

 }

 

输出

100

200

以上就是详细介绍C#中new的几种用法的详细内容!

返回前面的内容

相关阅读 >>

C#中winform制作异形窗体与控件的实现方法

C#中default什么意思

实现C#listview点击列头排序的示例代码分享

C#灵活使用类的方法分享

使用C#生成pdf文件流的代码案例分享

C#实现与现有.net事件桥接的简单代码

C# windowsapi应用之getdesktopwindow-获得桌面所有窗口句柄的方法详解

C#用什么软件编程?

讲解什么是msmq

C#中如何操作word的方法示例

更多相关阅读请进入《C#》频道 >>




打赏

取消

感谢您的支持,我会继续努力的!

扫码支持
扫码打赏,您说多少就多少

打开支付宝扫一扫,即可进行扫码打赏哦

分享从这里开始,精彩与您同在

评论

管理员已关闭评论功能...