My code is a service that needs to output different status codes as follows:
if(something is valid) { if(this is found) return "200"; else return 300; } else return "100"; There are many such status codes and also occur at various places in the application. So, I would like to declare them as constants at one place and use them, so as not to hard code the strings.
something like
public struct StatusCodes { public static string 100 = "100"; public static string 200 = "200"; } and be able to use it as
else return StatusCodes.100 Is there a standard practice or a good way to do so.
StatusCodes.100, but maybe you could name them by their description and give their value the real error code? i.e.public static string SomeCertainError = "100";something is validwithsomething == valid. Usually numbers (integers/longs) are more efficient than strings.enumis useful. SeeEnum.Parseetc for advanced features. Just reading up onenumand examples should help you out a lot here.