Hi Mehdi,
global::myNameS pace.Properties .Resources.myFi eld
However, I would like to retreive it's string representation of the
field's name, i.e., the "myField". How am I supposed to do that?
Hard-coding the string into your program might be your best bet if you only
want a limited number of strings. After all, the string "myField" is a
constant that you define at design-time.
I don't see how you could possibly retrieve the key name at runtime without
using the key name to find that resource item, but if you want to retrieve
all of the key names in your Resources object try the following code:
foreach (DictionaryEntr y resourceEntry in
Properties.Reso urces.ResourceM anager.GetResou rceSet(
System.Globaliz ation.CultureIn fo.CurrentUICul ture, true, true))
{
string keyName = resourceEntry.K ey;
}
The second question is that is there anyway to keep a "name/value"
collection within a resource file?
I can think of a few options:
1. Serialize a Dictionary, Base64 encode it, then hard-code the value into
the resource grid.
(To read it you must unencode it and deserialize it back into a
Dictionary)
2. Use a delimited format like key=value[,key=value...] and parse the
resource into a Dictionary at runtime.
3. For option #2 you could use = and & as delimiters and encode each key and
value as if they were urls.
4. Use an xml file instead of an embedded resource.
5. Use a database.
- Dave Sexton
"mehdi_mous avi" <me***********@ gmail.comwrote in message
news:11******** **************@ p79g2000cwp.goo glegroups.com.. .
Hi folks,
Consider a string that's defined under VS2005 resource editor as
myField with the value of myValue. To access the value, I could easily
use the Properties.Reso urces class, for example:
global::myNameS pace.Properties .Resources.myFi eld
However, I would like to retreive it's string representation of the
field's name, i.e., the "myField". How am I supposed to do that?
The second question is that is there anyway to keep a "name/value"
collection within a resource file?
Any help would be highly appreciated,
Cheers,
Mehdi