Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<h2>Access modifiers</h2> <blockquote> <p><strong>public</strong></p> <blockquote> <p>The type or member can be accessed by any other code in the same assembly or another assembly that references it.</p> </blockquote> <p><strong>private</strong></p> <blockquote> <p>The type or member can only be accessed by code in the same class or struct.</p> </blockquote> <p><strong>protected</strong></p> <blockquote> <p>The type or member can only be accessed by code in the same class or struct, or in a derived class.</p> </blockquote> <p><strong>internal</strong></p> <blockquote> <p>The type or member can be accessed by any code in the same assembly, but not from another assembly.</p> </blockquote> <p><strong>protected internal</strong></p> <blockquote> <p>The type or member can be accessed by any code in the same assembly, or by any derived class in another assembly. </p> </blockquote> </blockquote> <p>When <strong>no access modifier</strong> is set, a default access modifier is used. So there is always some form of access modifier even if it's not set.</p> <p><strong>Static</strong></p> <blockquote> <p>The static modifier on a class means that the class cannot be instantiated, and that all of its members are static. A static member has one version regardless of how many instances of its enclosing type are created.</p> <p>A static class is basically the same as a non-static class, but there is one difference: a static class cannot be externally instantiated. In other words, you cannot use the new keyword to create a variable of the class type. Because there is no instance variable, you access the members of a static class by using the class name itself.</p> <p>However, there is a such thing as a <a href="http://msdn.microsoft.com/en-us/library/k9x6w0hc%28v=vs.80%29.aspx" rel="noreferrer">static constructor</a>. Any class can have one of these, including static classes. They cannot be called directly &amp; cannot have parameters (other than any type parameters on the class itself). A static constructor is called automatically to initialize the class before the first instance is created or any static members are referenced. Looks like this:</p> </blockquote> <pre><code>static class Foo() { static Foo() { Bar = "fubar"; } public static string Bar { get; set; } } </code></pre> <p>Static classes are often used as services, you can use them like so:</p> <pre><code>MyStaticClass.ServiceMethod(...); </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload