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 1104829
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T01:32:21+00:00 2026-05-17T01:32:21+00:00

Apparently there is no predefined list available in .net. I’d like to use a

  • 0

Apparently there is no predefined list available in .net.

I’d like to use a number of standard colors, e.g. something like red, green, blue, yellow, … i.e. the typical colors consisting of 00 and FF components, followed by those with additional 7F components, …

Is there a way to retrieve these “standard” colors or do I have to write the IEnumerable<Color> myself?

Edit: This is a possible output for the RGB values.

Please note that order of sets matters in that the 00/FF enumeration has to be complete before 80 is added, and the 00/80/FF enumeration has to be complete before adding 40/B0, and so on. The order within a set does not matter (i.e. 00 FF 00 may come before 00 00 FF).

00 00 00 // start out with 00 and FF components
00 00 FF
00 FF 00
FF 00 00
FF FF 00
FF 00 FF
00 FF FF
FF FF FF
00 00 80 // ok, now add 80
00 80 00
...
80 80 80
FF 00 80
FF 80 00
FF 80 80
80 FF 00
80 FF 80
FF FF 80
...
// now add 40 and B0
  • 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-17T01:32:21+00:00Added an answer on May 17, 2026 at 1:32 am

    This is a reasonably fast way to generate the sequence:

    public static IEnumerable<Color> StandardColors ()
    {
        int r = 0;
        int g = 0;
        int b = 0;
        int inc = 0x100;
    
        yield return Color.FromArgb (0, 0, 0);
    
        while (true) {
            if (((r | g | b) & inc) != 0) {
                int outR = r == 0 ? 0 : r - 1;
                int outG = g == 0 ? 0 : g - 1;
                int outB = b == 0 ? 0 : b - 1;
                yield return Color.FromArgb (outR, outG, outB);
            }
    
            r += inc;
            if (r > 256) {
                r = 0;
                g += inc;
    
                if (g > 256) {
                    g = 0;
                    b += inc;
    
                    if (b > 256) {
                        b = 0;
                        inc >>= 1;
    
                        if (inc <= 1) {
                            break;
                        }
                    }
                }
            }
        }
    }
    

    This can certainly be improved. For instance, having a separate outR/G/B variable should be avoided, and incrementing should be via 2*inc starting from an odd (based on inc) value to avoid having to test if the value was already generated earlier.

    Using this test

    static void Main (string[] args)
    {
        var colors = StandardColorEnumerator.StandardColors ().Take (15)
            .Concat (StandardColorEnumerator.StandardColors ().Skip (1000).Take (10));
        foreach (var color in colors) {
            Console.WriteLine (color.B + "\t" + color.G + "\t" + color.R);
        }
    
        Console.ReadKey (true);
    }
    

    the following output is generated:

    0       0       0
    0       0       255
    0       255     0
    0       255     255
    255     0       0
    255     0       255
    255     255     0
    255     255     255
    0       0       127
    0       127     0
    0       127     127
    0       127     255
    0       255     127
    127     0       0
    127     0       127
    
    15      47      191
    15      47      207
    15      47      223
    15      47      239
    15      47      255
    15      63      0
    15      63      15
    15      63      31
    15      63      47
    15      63      63
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

No related questions found

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.