Reputation: 9377
As the title says then the question is relative simple however I cant decide whether a resource file with strings in is better than hard-coded strings... Whats your opinion?
Thanks in advance
Upvotes: 6
Views: 4247
Reputation: 19365
Have a realistic look at your application.
Reasons for resource files:
Reasons for hard-coded strings:
Upvotes: 3
Reputation: 33153
I prefer to use the web config file (so a resource file). Hard-coded strings could be duplicated across your code and are much more difficult to "find and replace". Hence, you are prone to error if you have the same hard coded string across any application be it asp.net, C#, vb.net etc.
If you have a resource file with a central place that stores connection information you will sleep better at night. Your other option is to use some sort of constant and reuse that constant across your pages.
Upvotes: 0
Reputation: 81660
Main advantage is in localisation. Performance wise resources have a little more overhead but really not much of an issue.
If I am not worried at all about localisation then I would use constants (and not hard-coded strings).
Upvotes: 5