Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Should I store my global constants in resources file (.resx) or in classes?

Tags:

c#

.net

constants

I have a plenty of them of different form and types. Of course I will not store a bitmap as const, and I know about localization strings, but what should I do with other constants?

like image 601
Dan Ganiev Avatar asked Nov 10 '10 07:11

Dan Ganiev


People also ask

What is resource ResX file?

resx resource file format consists of XML entries. These XML entries specify objects and strings inside XML tags. It can be easily manipulated.

What is the use of ResX file in c#?

Resources in . resx files. Unlike text files, which can only store string resources, XML resource (. resx) files can store strings, binary data such as images, icons, and audio clips, and programmatic objects.

How to add data in ResX file c#?

Call the ResXResourceWriter. AddResource method for each resource you want to add to the file. Use the overloads of this method to add string, object, and binary (byte array) data. If the resource is an object, it must be serializable.


1 Answers

Put constants that relates to UI display in resources.
Put "constants" relating to application configuration like connection strings in app.config
Put constants that relates to program flow in c# classes.

like image 107
Albin Sunnanbo Avatar answered Oct 24 '22 10:10

Albin Sunnanbo