I came across something very peculiar, I use resource files to translate strings into a working draft, and at the moment I have a piece of code that iterates through these resource files to find localized versions of Questions and answers related to the page often questions, then scroll through them and draw on the page.
The problem is that one of my loops works perfectly and the other just goes straight to Answer2!
My code is below, I really canβt understand why 2 parts of the code give different results in the same way!
if (LanguageStrings.Culture == null)
{
LanguageStrings.Culture = new CultureInfo("en-gb");
LanguageStrings_FAQ.Culture = new CultureInfo("en-gb");
LanguageStrings_FAQAnswers.Culture = new CultureInfo("en-gb");
}
CultureInfo ResxCulture = new CultureInfo(LanguageStrings.Culture.Name);
List<string> FAQQuestions = new List<string>();
ResourceSet RS = LanguageStrings_FAQ.ResourceManager.GetResourceSet(ResxCulture, true, true);
foreach (DictionaryEntry entry in RS)
{
FAQQuestions.Add(entry.Value.ToString());
}
List<string> FAQAnswers = new List<string>();
ResourceSet RSAnswers = LanguageStrings_FAQAnswers.ResourceManager.GetResourceSet(ResxCulture, true, true);
foreach (DictionaryEntry entry in RSAnswers)
{
FAQAnswers.Add(entry.Value.ToString());
}
The first element in RS is 0, which has a Questions 0 key, as I would expect, but in the second loop index 0 Answers2!
Can someone point me to why this situation is happening?