C#: Can i write "private:" or "protected:" regions like in C++
In C++ you can write:
private:
int 开发者_如何学Gow;
string x;
protected:
int y;
string z;
is there something similar in C# ?
No, there are no regions with a specific access type in C#. Every member of a class
or struct
must have an explicit access modifier or accept the default access modifier private
.
Also, on the topic of access modifiers in C# compared to C++, C# has two additional modifiers internal
and protected internal
. The modifier internal
means that it is visible only within the defining assembly and protected internal
means protected
or internal
(NOT protected
and internal
).
you can't but see this it could help
private int x,y,z; private string x,y,z
You could define your region with #region Private...#endregion
, #region Protected...#endregion
etc.
精彩评论