Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Reading from resource files

Status
Not open for further replies.

tshad

Programmer
Jul 15, 2004
386
0
0
US
I am trying to read from the resource files to fill my dropdowns in different languages.

I found a couple of ways to do it but found two online that give me errors:

Code:
ResourceSet resourceSet = LocalizedText.ResourceManager.GetResourceSet(CultureInfo.CurrentUICulture, true, true);
return from entry in resourceSet.Cast<DictionaryEntry>()
	where entry.Key.ToString().StartsWith(prefix)
	select new KeyValuePair<string, string>(
	entry.Key.ToString().Substring(prefix.Length + 1), entry.Value.ToString());

Here the error is on: "resourceSet.Cast<DictionaryEntry>
"System.Resource.ResourceSet does not contain a definition for "Select"

Code:
ResourceSet resourceSet = LocalizedText.ResourceManager.GetResourceSet(CultureInfo.CurrentUICulture, true, true);
var resourceDictionary = resourceSet.Select(r => (DictionaryEntry)r)
	 .ToDictionary(dicEntry => dicEntry.Key.ToString(),
				dicEntry => dicEntry.Value.ToString());

This one gives me this error on: "resourceSet.Select(r => (DictionaryEntry)r)"
"System.Resource.ResourceSet does not contain a definition for "Select"

What do I need to do to make these work?

Thanks,

Tom
 
Found this in:
System.Object
System.Resources.ResourceSet
System.Resources.ResXResourceSet

It doesn't say anything about "select" but "Cast" is an extension method. And the namespace is "System.Resources", which I have in my using area.

So it should work.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top