Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3231514
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T17:03:16+00:00 2026-05-17T17:03:16+00:00

ResourceSet rs = Resources.Loading.ResourceManager.GetResourceSet(CultureInfo.CurrentCulture, true, true); so far I have that line, which gets

  • 0
ResourceSet rs = Resources.Loading.ResourceManager.GetResourceSet(CultureInfo.CurrentCulture, true, true);

so far I have that line, which gets me all the loading messages,

my problem is the ResourceSet is an IEnumerable. I can’t figure out what the best way to return a random string in this enumerable would be.

Ideally I’d do something like rs[Utility.Random(rs.Length)]

but I can’t figure out how to cast the ResourceSet as a List (for instance), so I don’t have to resort to an abomination like a manual loop with something horrible like:

    public static string RandomLoadingMessage()
    {
        ResourceSet rs = Resources.Loading.ResourceManager.GetResourceSet(CultureInfo.CurrentCulture, true, true);

        int count = 0;

        foreach(object res in rs)
            count++;

        int position = Utility.Random(count);

        count = 0;

        foreach(DictionaryEntry res in rs)
        {
            if(count++ == position)
                return res.Value.ToString();
        }

        return string.Empty;
    }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-17T17:03:16+00:00Added an answer on May 17, 2026 at 5:03 pm

    Since you mentioned that you have access to LINQ, you can use the Enumerable.Cast<TResult>() extension method to convert the IEnumerable to its generic version (IEnumerable<DictionaryEntry>):

    static Random rng = new Random(); // outside of method...
    
    // ...
    
    ResourceSet rs = rm.GetResourceSet(CultureInfo.CurrentCulture, true, true);
    var resources = rs.Cast<DictionaryEntry>();
    string randomValue = resources.ElementAt(rng.Next(0, resources.Count())).Value.ToString();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a C# custom control that loads images from Resources.resx. I was loading
I have a library loading the resources from an external file as follows: ResourceManager
I have a nested resource that looks like this: resources :events resources :attendances post
I have a resources web app, which only has static content, such as images,
My problem is that the image loading seems to be uncorrectly from application resources.
I'm having trouble loading an image from My.Resources. I have already tried a no.
I'd like to have a splash screen while loading resources (images and sounds). How
I'm working on an AJAX based application that is dynamically loading in resources (external
I'm loading string resources from a text file (so as to not have to
I have problem with loading resources for UserControl from referenced assembly in Expression Blend

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.