What are the benefits of resource files (.resx)?

What good reasons exist for their use?

+56
c # resx
Jul 15 '09 at 20:56
source share
5 answers
  • Resource files give you an easy way to localize / internationalize your .net applications by automatically determining which resx language file to use based on the user locale. To add other languages, just add another translated resource file.

  • Resource files provide you with a central place to store your lines, files, and scripts and reference them in a strongly typed manner (therefore, compilation will fail if you reference them incorrectly).

  • Resource files can be compiled into satellite assemblies, making it easy to change resources in a production application without having to recompile it all.

+61
Jul 15 '09 at 21:02
source share

As a complement to the other answers that I supported, I would like to add that string resources are for human readable text, not constants that will be used programmatically. They are great for error messages, button shortcuts, etc.

Very often, instead of the final string, we save the format string so that variables can be replaced at the last moment. The best part about this method is that, unlike concatenation, it does not interrupt when a language has different requirements for word order.

+19
Jul 15 '09 at 21:05
source share

With resx, you can have one in one language (it is a spoken language, not a programming language), allowing your program / system to be multilingual.

+12
Jul 15 '09 at 21:01
source share

Resource files allow you to change the text / graphics displayed by your program without editing the code of the program itself. For many reasons, it is often considered ideal to avoid having to edit the program source code to make changes that are not part of your application logic.

+10
Jul 15 '09 at 21:08
source share

In addition to the answers above, resource files can also provide you with a place to store test files for performing read / write tests. Thus, no matter how the environment is configured for other people, you may have a place to store logs or other files.

Keep in mind that the files you place in resources must be serialized. See below for more details:

https://msdn.microsoft.com/en-us/library/f45fce5x(v=vs.80).aspx

0
Jul 22 '16 at 19:13
source share



All Articles