I am using C++ Language and learning in C#.
But I used to set Public modifier as
class cls
{
-----param
public :
-----method and param
}
Why C# don't have this. I think all modifier should be able to set as this method like C++. And can set like Java too.
Or Microsoft has some reason

Why Modifier can't be set like C++
JeanL
Kevin McElhiney
sorry, can you explain a bit more in depth
Matt Lin
SmallTalk and C++ Access Modifier was able to applied to more than one member by one cast.
with "public :" or "private :" or "protected :" in 1 row
Why C# can't
Tom McAnnally
Moving this thread to the C# Language Forum as this is a question about the language, not the IDE.
-Tom Meschter
Software Dev, Visual C# IDE
NeilCFD
Sqnyy
Yes,Right. Thank you Mr.Peter.
And so, we can use private and protect with this technic.
And if Microsoft try to do. We may be able to set static,const, or any type modifier
like this
class class1
{
//private :
int x,y,z;
static :
const int A = 20;
protected :
const double B = 5;
int C;
public :
int M(){};
int N(){};
private int O()
{M() * N()};
int Z()
{O()};
}
if this have more than 20 method. it may so tired.
Set modifier like SmallTalk have more Advantages
So why Microsoft remove this ability I want to know
mattdawg
Yes this is true and its not possible in C#.
Best Regards,
Rizwan
markand
cka11
It's because the separate access modifier syntax is prone to getting disconnected from what it applies to. For example, with larger class definitions:
class SomeClass {
int value1;
int value2;
public:
int value3;
int value4;
int value5;
int value6;
int value7;
int value8;
int value9;
int value10;
int value11;
int value12;
int value13;
int value14;
int value15;
int value16;
int value17;
int value18;
int value19;
int value20;
int value21;
int value22;
int value23;
int value24;
int value25;
int value26;
int value27;
int value28;
int value29;
int value30;
int value31;
int value32;
//...
};
it's easy to scroll down to the bottom of the class and not know what the access is for a value because the access specifier applies to it could be several dozen lines above it. Cutting and pasting lines of code exacerbates this because the location of a line of code essentially defines it's access level. Because of this access specifiers must be applied directly to each member declaration (if the default is not sufficient).
Meltdown61
Yes,so I want to know why it can't
Why microsoft can't make VC# to set any modifier in 2 ways
like Java as it is.
And like SmallTalk as VC++ can be.
Microsoft have any reason to remove this Syntax, Or it have any problem
Or they forgot to do