labeling a group of members as private/public in c#

情到浓时终转凉″ 提交于 2019-12-01 22:18:57

问题


in a c++ class declaration, you can label a group of members as private or public, e.g.

private:
  int x;
  double y;

seems like there's no way to do this in c#. am I wrong?


回答1:


No, you can't not do this in C#.

At best, you can use the default visibility for members, which is private, and not use private, but for public, you have to indicate it for all members.




回答2:


You're correct. Although, if you leave visibility keyword off altogether, a member defaults to private.




回答3:


No you're not wrong. If you don't write any modifiers it will be assumed as private.



来源:https://stackoverflow.com/questions/546869/labeling-a-group-of-members-as-private-public-in-c-sharp

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!