In my application (C#) i have lots of const messages which are get printed to the log, presented to the user, etc. This const messages are not suppose to change so there is no point putting them in an external file or DB. My solution is very simple - I am thinking about creating a static class and naming it ConstMessages. This class will simply hold lots of public const string variables which can be accessed from anywhere in the application. Can you please suggest if there anything wrong with that method and if there are better ways? Thanks!
I would use readonly instead of const to get over versioning issues.
That's usually OK for simple applications - another option is a RESX file if you think there is a possibility the application will ever need to be localized / support more than one language.
I would typically store these as application Settings or Resources.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With