We Recommend

Accelerated C# 2008 Accelerated C# 2008
This book is both a rapid tutorial and a permanent reference. You’ll quickly master C# syntax while learning how the CLR simplifies many programming tasks. You’ll also learn best practices that ensure your code will be efficient, reusable, and robust. Why spend months or years discovering the best ways to design and code C# when this book will show you how to do things the right way, right from the start?


Posted By

faltumk on 02/08/07


Tagged

csharp ResourceFiles


Versions (?)


CSharp Reading String from Resource File .


Published in: C# 


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.


  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 

You need to login to post a comment.