Search code examples
c#stringresx

RESX vs Static Class


  1. Should I use a .resx file or a static class to store my strings?
  2. What are the pros and cons for each?

I know that using a .resx means you don't need to compile the project every time you change a string, but are there any other pros/cons?


Solution

  • Another point can be come to your mind while using resource file is

    Will a resource file work properly for large amounts data?

    I think the limitation is the file-size limitation of the operating system and that is 4 GB on 32 Bit systems, if I remember correctly. For 64 bit it should be even bigger. Anyway, for the purpose to store the static text, it should be more than enough.

    Thus, in my opinion, this should not be done anywhere else if the text will be static.

    An alternative approach would be creating a class to control access to your resource files. This class might be used to store the keys to access your resource files and a have strongly typed way to retrieve available resources of the project.

    Some references on SE answers on resources:

    Resource string location

    Using .resx files for global application messages

    References from MSDN :

    Resource Files (Visual Studio)