CSharp Reading String from Resource File .


/ Published in: C#
Save to your folder(s)

The resource file stores items as name-value pair.
To get string values from the resource files (.resx) added in your project, use the following code.


Copy this code and paste it in your HTML
  1. /*
  2. The resource file stores items as name-value pair.
  3.  
  4. To get string values from the resource files (.resx) added in your project, use the following code.
  5. */
  6.  
  7. //Name Spaces Required
  8. using System.Resources;
  9. using System.Reflection;
  10.  
  11. // Create the resource manager.
  12. Assembly assembly = this.GetType().Assembly;
  13.  
  14. //ResFile.Strings -> <Namespace>.<ResourceFileName i.e. Strings.resx>
  15. resman = new ResourceManager("StringResources.Strings", assembly);
  16.  
  17. // Load the value of string value for Client
  18. strClientName = resman.GetString("Client");

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.