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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T13:12:35+00:00 2026-06-05T13:12:35+00:00

My idea was to switch between some colors, so I don’t have to use

  • 0

My idea was to switch between some colors, so I don’t have to use multiple pens but I can declare just one.

I’m not so sure to have understood exactly how enums work, please correct me:

type ColorType =
  | Red = Color.Red
  | Green = Color.Green
  | Blue = Color.Blue

and I wish to use it in:

let p = new Pen(ColorType.[index])
g.DrawRectangle(p, 0, 0, 10, 10)

where index is an int variable (0 to 2) I’ll use to switch my colors. The problem is that I can’t declare that enum, Color is not accepted. Possible solutions?

  • 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-05T13:12:36+00:00Added an answer on June 5, 2026 at 1:12 pm

    To access the colors by index, you could put them in an array:

    let colors =
      [|
        Color.Red
        Color.Green
        Color.Blue
      |]
    
    let p = new Pen(colors.[index])
    g.DrawRectangle(p, 0, 0, 10, 10)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to switch between 3 pictures fading in and out between them but
In order to switch between views in my iOS app, I have been using
I have a label control where I use a converter to switch its styles
I'm using the Switcher in Intellij IDEA to switch between editor tabs a lot.
I have an iphone application that crashes when I switch between two of the
is there a way to use the a.vim plugin to switch between .h, .cxx
Idea: I want to make smth like real time electronic blackboard. Many users have
The Idea I have a main PHP page that loads content in DIV's from
The idea is to walk over multiple dimensions, each one defined as a range
Any idea how to join multiple tables in ssis programatically using Merge Join ?

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.