Static class
-
-
Hi, i have wrote this code to create a static class public static class Tools { public static Tools() {} } but the complier give me this error : The modifier 'static' is not valid for this item. (referring to the class declaration) What i miss? thanks
Hello You've missed reading MSDN: "The static modifier can be used with fields, methods, properties, operators, events and constructors, but cannot be used with indexers, destructors, or types." With best regards, Andrew
-
Hi, i have wrote this code to create a static class public static class Tools { public static Tools() {} } but the complier give me this error : The modifier 'static' is not valid for this item. (referring to the class declaration) What i miss? thanks
-
Hi, i have wrote this code to create a static class public static class Tools { public static Tools() {} } but the complier give me this error : The modifier 'static' is not valid for this item. (referring to the class declaration) What i miss? thanks
A static class can't create an object and thereby it can't have a construcor. The PROgrammer Niklas Ulvinge aka IDK
-
Hi, i have wrote this code to create a static class public static class Tools { public static Tools() {} } but the complier give me this error : The modifier 'static' is not valid for this item. (referring to the class declaration) What i miss? thanks
-
A static class can't create an object and thereby it can't have a construcor. The PROgrammer Niklas Ulvinge aka IDK
Thats wrong. In .Net static constructors are allowed which are called the first time the class is used:
public class Blubb() {
static Blubb() {
//Do something
}
}Note that no more modifiers are allowed and that this constructor cannot be called explicitely (the framwork handles this).
-
Thats wrong. In .Net static constructors are allowed which are called the first time the class is used:
public class Blubb() {
static Blubb() {
//Do something
}
}Note that no more modifiers are allowed and that this constructor cannot be called explicitely (the framwork handles this).
OK thanks. I didn't know that. I'll maby use it someday. The PROgrammer Niklas Ulvinge aka IDK
-
Hi, i have wrote this code to create a static class public static class Tools { public static Tools() {} } but the complier give me this error : The modifier 'static' is not valid for this item. (referring to the class declaration) What i miss? thanks