views:

186

answers:

3

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  A: 

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

Mohammadreza
I believe that members without a visibility modifier will be implicitly made internal, not private.
Michael Meadows
Internal is default for classes and structures and for their members private is default.
Mohammadreza
+4  A: 

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.

casperOne
+1  A: 

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

C. Dragon 76