Oktatás * Programozás 2 * Szkriptnyelvek * levelezősök Félévek Linkek * kalendárium |
CSharp /
20180407cClass access modifiersstatic class: the class cannot have instance variables or methods. They must all be static. The compiler will check this for you. static constructor: initialize static class variables public class Something { public static int sharedNumber; // class variable, belongs to the class static Something() { Something.sharedNumber = 3; } } Of course, here we could have simply written internal: it can be used inside the current project or assembly. An assembly is usually a single project in a compiled form (a single EXE or DLL). class Book { ... } For a class the default access modifier is inernal, thus the code above is equivalent to this: internal class Book { ... } If you want to use the class outside of the original project, then make it public: public class Book { ... } |
Blogjaim, hobbi projektjeim * The Ubuntu Incident [ edit ] |