.NET Resource files


Scenario:

Based on locale or other variable select the value of a config.


Version
IDValue
1true
2false

Steps:


  1. New File -> Resource file [.resx]. It is key value pair file
  2. NameValue
    1true
    2false
      
  3. In your class add below code:
    1
    2
    3
    4
    5
    6
    7
    8
    private readonly ResourceManager _resourceManager = new ResourceManager(
                "MyProject.MyApp",
                Assembly.GetExecutingAssembly());
    
    ...
    ...
    
    var _versionQuery = _resourceManager.GetString(ConfigurationManager.AppSettings["version"]);
    


Output:

Config [version]Return Value
1true
2false

No comments:

Post a Comment

Move Github Sub Repository back to main repo

 -- delete .gitmodules git rm --cached MyProject/Core git commit -m 'Remove myproject_core submodule' rm -rf MyProject/Core git remo...