You cannot call a private static property on an instance of a class in C#. Private static properties are only accessible within the class in which they are declared.
However, you can create a public static method within that class that accesses the private static property and returns its value. Then you can call that static method on an instance of the class.
For example, consider the following class with a private static property:
main.cs78 chars5 lines
To access the value of myPrivateStaticProperty
from an instance of MyClass, you can create a public static method that returns its value:
main.cs182 chars10 lines
Then you can call GetMyPrivateStaticProperty()
on an instance of MyClass:
main.cs86 chars3 lines
gistlibby LogSnag