public makes it available everywhere.
private makes it available from the same class only.
If you have no accessor, it appears to me that it defaults to private. Both variables and functions. Is there any difference between no accessor and private accessor?
Here is the msdn article covering how access modifiers work:
A class defaults to private.
There is no difference between private and no accessor for a class member.
class Foo
{
private int valueA;
int valueB;
}
In this example the class will be ‘internal’, and both valueA and valueB will be private.
It defaults to private because it’s a class. A class is intended to be an encapsulated object, so therefore members should be private first and only made public explicitly.
Though funny enough structs also default to private as well (unlike say C++). I think this is for consistency sake? I don’t know the MS rationale for it.
To add info to the original poster’s question, which @lordofduct answered perfectly, you can also use getters and setters and explicitly control their publicness/privateness and protectedness, which is useful for communicating the intended scope of various fields. The most common is something like: