Jul 21, 2011

Resource strings c#

First make sure that you have resource file available for the current culture in which your thread is running or you have default resource file for example your strings collection is in a resource file name Resource.resx then for each culture you have to create the different file. For example for USA you have to create the Resource.en-US.resx.
How ever if you don't want to create resource file for each culture then you can create default file that will be Resource.resx.















after setting the resource string in resource.resx the code for accessing  resource string is 





using System.Resources;
using project name(ur project name).Properties;




private void lnkEvntlogs_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            MessageBox.Show(Resources.IDS_EVENTLOGS_INFO);
        }




the output of the resource string is 







No comments:

Post a Comment