As far as I know, in C# all fields are private for default, if not marked otherwise.
class Foo
{
private string bar;
}
class Foo
{
string bar;
}
I guess these two declarations are equal.
So my question is: what for should I mark private variables as private
if they already are private?
Now; fields should pretty-much always be private anyway, so it is an edge case whether you should bother.
For the wider subject, I remember a comment by Eric Lippert - essentially saying that given a method / class / whatever:
void Foo() {}
class Bar {}
Then it isn't clear whether they are private/internal deliberately, or whether the developer has thought about it, and decided that they should be private/internal/whatever. So his suggestion was: tell the reader that you are doing things deliberately instead of by accident - make it explicit.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With