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

Question 1 A small Canadian law firm specializing in immigration law has what it considers a successful website. One of the most popular features of the website is its newslet

What is DCOM? DCOM is different from COM in that it allows for creating objects distributed around  a network, and a protocol for invoking that object's methods, & secures the

What is Multi-threading? Multi-threading process forms the subset of Multi-tasking. Inspite of having to switch between programs this feature switches between different parts o

Experienced Microsoft .NET web developer The developer must be reliable as well as most of all use best practices for coding as well as application design. a) .NET 3.5 (ideal

Program of Declaring a function - C# Program Program of Declaring a function, I am looking for a program in C#. It would be great if anyone help me learn function in C# langua

How can we use Culture Auto in project? We will make a very simple login screen which we will try to use for English as well as the Greek. The login screen will display Engl

hello,i want to ask that i have to make a test taker just like a quiz in vb.net which should b like mcq''z one...it must contain a connectivity with database of oracle or MS access

Question: (a) Outline four classes that allow you to work with File Streams. (b) (i) What potential problem can arise when you change items stored in an Application State

Prepare an Application in C# or C++ Project Description: We are seeking someone who can write a program in C# or C++. The concept is to develop the program using a Cross P