C#10:命名空间范围的访问修饰符
正如标题所示,我很想在 C# 中看到这一点。
namespace PrivateStuff; //note: filescope namespace here!
public class PartiallyVisibleOutside
{
public int A;
namespace int B;
}
public class Test
{
public PartiallyVisibleOutside NC {get; private set;}
public void DoSmth()
{
NC.A = 100000 + NC.B; //OKAY til now!
Console.Write(NC.A);
}
}
//
namespace OUTSIDE;
public class OutsideClass
{
public PartiallyVisibleOutside Test;
void DoSmth()
{
Test.A = 100; //OKAY
Test.B = 100; //Compiletime-Error!
}
}
这样的事存在吗?或者我应该在 C# 上打开一个功能请求
As in the title, I would love to see this in C#.
namespace PrivateStuff; //note: filescope namespace here!
public class PartiallyVisibleOutside
{
public int A;
namespace int B;
}
public class Test
{
public PartiallyVisibleOutside NC {get; private set;}
public void DoSmth()
{
NC.A = 100000 + NC.B; //OKAY til now!
Console.Write(NC.A);
}
}
//
namespace OUTSIDE;
public class OutsideClass
{
public PartiallyVisibleOutside Test;
void DoSmth()
{
Test.A = 100; //OKAY
Test.B = 100; //Compiletime-Error!
}
}
Does smth like this exist? Or shall i open up a feature-request at C#
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
没有这样的功能,我认为在近功能中实现它是非常利基的事情。尽管您可以通过将
Test
和PartiallyVisibleOutside
移动到单独的项目(程序集)并将B
标记为内部
。There is no such feature and I think it is very niche thing to be implemented in near feature. Though you can simulate it by moving
Test
andPartiallyVisibleOutside
into separate project (assembly) and markingB
asinternal
.