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
I need Windows 8.1 Project, Asset management slate App Project Description: We are seeking a Windows 8 app developer with PROVABLE experience to prepare a project and asset m

how can i construct er diagram for payroll managment

Php project for Narivramanarao For email Project Description: This is a project for Narivramanarao for emails and for php.rar please bid on the project and let's get started

I need Kinect Developer c++ We are creating a fitting room with Kinnect and I need some questions answered like how to detect if a person turns around, how to make the clothing

Project Description: We require an expert developer to work on several projects for our company. You will be managed by our senior developer. Required - MUST be proficient in

Project Description: We are seeking experienced .NET developers (possibly certified) to work with us on several future projects. You will have to pass a simple test to be consid

Explain Interface? An interface is not a class. It is an entity that is explained by the word Interface. An interface has no implementation; it only has the signature or in oth

Image Generator (Ngen.exe) The Ngen.exe (Native Image Generator) allows you to run the JIT compiler on your assembly's MSIL and generate native machine code which is cached to

What is the AppFabric component? The AppFabric component is used to make access control and dole out messages across clouds and enterprises. It has a service-oriented architect

I have a application on web i am getting some issue please make changes and help me out ..please help me Skills required: .NET, MySQL, PHP, ASP, Visual Basic