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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T13:52:44+00:00 2026-06-09T13:52:44+00:00

This might get downvoted, but this question has been bothering me since yesterday.. until

  • 0

This might get downvoted, but this question has been bothering me since yesterday.. until I found a link then I knew I wasn’t really crazy lol:
Enum as instance variables

I’m basically asking the opposite of the OP’s question. Given:

enum Coffee {
    BIG,
    SMALL }

public class MyClass {
    private Coffee coffee;

    // Constructor etc.
}

Although this is Java and enums do differ somewhat in both languages how is it that
I can’t do coffee.BIG or coffee.BIG.SMALL (though it makes little sense when reading it, it should be possible considering coffee is of type Coffee) in C#?

  • 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-09T13:52:45+00:00Added an answer on June 9, 2026 at 1:52 pm

    This isn’t really to do with enums. It’s to do with accessing static members in general.

    Java has a design flaw (IMO) which allows you to access static members as if they were instance members, via an expression of that type. It can lead to very confusing code:

    Thread thread = new Thread(...);
    thread.start();
    // This looks like it makes the new thread sleep, but it actually makes the
    // current thread sleep
    thread.sleep(1000);
    

    Additionally, there’s no nullity check as the value of the expression is irrelevant:

    Thread thread = null;
    thread.sleep(1000); // No exception
    

    Now, consider that enum values are implicitly static, and you can see why there’s the difference.

    The fact that you’ve acknowledged that “it makes little sense when reading it” suggests that at heart you agree that this is a flaw within Java, not within C# 🙂

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

Sidebar

Related Questions

This might seam like a strange question but.... public string MyProperty { get {
This might be a dumb question, but I don't get it: I have a
This might be a loaded question, and it might get voted down, but it
This might be a very simple question but i am unable to get it.
This might be a dumb question but I can't get this super simple script
This might be a simple question but now i started working on GET method
I expect this might get some downvotes / closevotes but I'm going to ask
This might sound daft but how do you get silverlight to run as a
This might seem like a very easy question for some of you folks, but
This might be a simple question but I've searched and searched and can't find

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.