views:

54

answers:

1

Hello

I want to read all the strings from a resx file and load it into an array without looping. I'm working in an asp.net web application and i'm using C#. How can i get the strings?

Thank you

NLV

+3  A: 
string[] AllStrings;
using (var Reader = new ResXResourceReader(fileName))
{
    AllStrings = Reader.Cast<DictionaryEntry>().Select(o => o.Value).OfType<string>().ToArray();
}
arbiter
The `Reader.GetEnumerator` returns an `IDictionaryEnumerator`, so every item that is returned is a `DictionaryEntry`. This will never be of type `string`. I think you need: `Reader.Select(o => o.Value).OfType<string>().ToArray()`
GvS
@GvS, yes you right, corrected my answer.
arbiter