Posted on 2004-08-30
I have a class writtne in Java with a large number of constants that I am currently porting to C#. I nested the constants in Java so that the code would be a bit more readable:
public class Class1
public static final class CONSTANTS
public static final String CONST1 = "CONST1";
public static final class NESTED
public static final String CONST2 = "CONST2";
I can then access the constants using code like:
String strTemp1 = Class1.CONSTANTS.CONST1;
String strTemp2 = Class1.CONSTNATS.NESTED.CONST2;
How could I do something similar in C#? I know that C# supports nested classes, but I also notice you cannot declare the class static. Does this mean every instance will get a separate copy of the class?
I've got only 70 points, and I'm putting them all up.