在c#.net中,我们可以实现私有类,也可以不实现 [英] In the c#.net we can implement private classes or not

查看:341
本文介绍了在c#.net中,我们可以实现私有类,也可以不实现的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在c#.net中,我们可以实现私有类,或者不能实现私有类.

In the c#.net we can implement private classes or not

推荐答案

是.
public class MyClass
   {
   ...
   private class MyInnerClass
      {
      public MyInnerClass()
          {
          }
      }
   private MyInnerClass mine = new MyInnerClass();
   }


内部类仅在MyClass中可用.
您也可以在类外但在相同的名称空间内创建它:


The Inner class is only available within MyClass.
You can also create it outside the class, but within the same namespace:

public class MyClass
   {
   private MyOtherClass mine = new MyOtherClass();
   ...
   }
private class MyOtherClass
   {
   public MyOtherClass()
       {
       }
   }

在这种情况下,它仅在名称空间中可用.

In this case it is available within the namespace only.




是的,可以肯定,我们可以实现私有类.但是没有用,因为它在外部无法访问

问候
Hi,

Yes for sure we can implement private classes. but there is no use to it becoz it is not accessible outside

regards


这篇关于在c#.net中,我们可以实现私有类,也可以不实现的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆