Strongly typed resource class, DOT NET Programming

Can we get a strongly typed resource class?

You can now get strongly types classes in the VS.NET intellisense as shown in the figure below.

42_resource class.png

Figure: - Strongly typed resource class

All belongs to the Resources namespace. Let do a small sample and see how the strongly typed classes work in the VS.NET 2005 and the simplicity which they bring while implementing globalization in the projects. The screen shot of the project is shown below. It is basically a simple login screen with user id and password text boxes. The User has options to select the language. Currently only two languages are provided English & Greek. Depending on the selected languages the user id and password label values will be displayed.

1013_resource class1.png

Figure: - Strongly typed project

The code snippet below describes the various important parts of the code. The First thing is the resource files. We have generated two resource files one for Greece with el and the second is the general resource file which will be used when the regional code does not match.

2357_resource class2.png

Figure: - Walkthrough for using the resources namespace

There are three main steps in the code:-

1) The First step is to set the culture information for the current thread with the new culture info object. The StrCulture has the language code which is presently selected in the drop down.

Thread.CurrentThread.CurrentCulture = new CultureInfo(strCulture);

2) We set the similar culture to the Resource class.

Resources.Resource.Culture = Thread.CurrentThread.CurrentCulture;

 3) Now we are all set to use the value.

lblUserId.Text = Resources.Resource.lblUserIdResource1.ToString();

lblPassword.Text = Resources.Resource.lblPasswordResource1.ToString();

Posted Date: 9/25/2012 3:55:28 AM | Location : United States







Related Discussions:- Strongly typed resource class, Assignment Help, Ask Question on Strongly typed resource class, Get Answer, Expert's Help, Strongly typed resource class Discussions

Write discussion on Strongly typed resource class
Your posts are moderated
Related Questions
What is Multi-tasking? It is a feature of the modern operating system with which we can run multiple programs at the same time for example Word, Excel etc.

If one of your validations is complicated and does not fit in any validators, what you do? The best way is to go for CustomValidators. The sample code for a custom validator

What is Absolute and Sliding expiration? The Absolute Expiration allows you to specify the duration of the cache, beginning from the time the cache is activated. The given exam

Data hiding and encryption would be done on images. Both these process should have a data hiding key and an encryption key correspondingly. Another user should be able to decrypt t

I need to create the subsequent iOS App/ iPhone (to be followed by Android & other platforms). Version 1.0--Users can: --Find events based on proximity/zipcode*/ location

How different are interface and abstract class in .Net? Abstract classes cannot be instantiated it can have or cannot have abstract method basically called as must inherit as t

I want simple code for Outlook (express,2003,2007,2010,2013) Add-In with functionality to routinely send CC to the specified email(s), this system should have -Code for every th

What precautions we need to take while deploying satellite assemblies? When we distribute the assembly, the folder structure has to be very organized. The table below shows how


Experienced Microsoft .NET web developer I have a various projects for which I need a web developer for. The developer will be the sole product owner hence should be dependab