labeling a group of members as private/public in c

2019-02-25 10:33发布

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?

3条回答
霸刀☆藐视天下
2楼-- · 2019-02-25 10:49

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

查看更多
Deceive 欺骗
3楼-- · 2019-02-25 10:56

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

查看更多
闹够了就滚
4楼-- · 2019-02-25 11:03

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.

查看更多
登录 后发表回答