Hello, I am just trying to understand using public and private with static.
I understand static constructors cannot be labelled with public or private.
However, can someone clarify properties, field and classes please?
If a property is static, then it already can only be accessed within the class itself.
What is the purpose of having a private or public static property as below?
Thank you 
Blockquote
public static int ForestsCreated
{
get { return forestsCreated; }
private set { forestsCreated = value; }
}
The static keyword doesnβt mean that a property or method can only be accessed within the class, but that you can access it directly from the class without first instantiating an object. The print/write methods on the Console class are static; you do not create a Console object and then call its methods. You just use Console.WriteLine()
, calling the WriteLine method directly on the Console class.
Public and private are different in that they affect which classes are allowed to interact with them.
2 Likes
Great explanation. Thank you !
1 Like