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

  • SEARCH
  • Home
  • 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 8960465
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T15:39:54+00:00 2026-06-15T15:39:54+00:00

Is this a clean and correct way to generate a list of consecutive uints

  • 0

Is this a clean and correct way to generate a list of consecutive uints?

The cast looks kind of ugly, but I’m a beginner…might be there is a method without casting around?

public class Test
{
    static readonly IEnumerable<uint> AvailableChannels 
         = (IEnumerable<uint>)Enumerable.Range(1,1000);
}
  • 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-06-15T15:39:55+00:00Added an answer on June 15, 2026 at 3:39 pm
    static readonly IEnumerable<uint> AvailableChannels 
         = Enumerable.Range(1,1000)
           .Select(i => (uint)i)
           .ToList();
    

    It’s still a cast though …

    EDIT
    The .ToList() is so the full list doesn’t need to be recreated every time you loop over it. (OK, a 1000 uints isn’t much, but it’s the principle of it – if they were classes you would create new ones every time and get unexpected results, like lost changes)

    EDIT2
    The Cast<uint>() doesn’t work at runtime (“Specified cast is not valid”). Changed to a .Select to perform the cast.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm sure there's a clean way to do this, but I'm probably not using
Is there an easy/clean way to do this in Linux/ a Linux-like environment? Purpose
How can I clean this up using rails 3 features? I have a post
Anyone have any ideas to clean this up? public string FullName { get {
My understanding of finalization is this: To clean up or reclaim the memory that
I found this css body { font: 13px/1.231 arial,helvetica,clean,sans-serif; *font-size: small; *font: x-small; }
This simple problem is kiling me. I posted something earlier about trying to clean
In an effort to 'clean up' my code - I was wondering if this
I am not a clean CSS coder, so this may be the crux of
This may seem obvious to most people, but I'm just trying to confirm that

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.