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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T04:26:44+00:00 2026-05-24T04:26:44+00:00

I am working on a project in C#, and for some reason, when I

  • 0

I am working on a project in C#, and for some reason, when I try to assign a value to an enum variable, the assignment does not happen. I would copy my code, but it is really just a simple assignment. It’s something like:

testVar = MyEnum.TYPE_OF_ENUM;

where testVar is of type MyEnum. When I step through this line using the VisualStudio debugger, I can see that the value of testVar does not change. What could possibly make an assignment fail like that?

EDIT:

Ok I will provide more context.

public enum MyEnum1
{
    ONE,
    TWO,
    THREE,
    FOUR,
    FIVE,
    SIX,
    SEVEN,
    EIGHT
}

public enum MyEnum2
{
    A,
    B,
    C,
    D,
    E,
    F
}

public void StateMachine(MyEnum1 state1)
{
    if(state2 == MyEnum2.A)
    {
        switch (state1)
        {
            case MyEnum1.ONE:
                state2 = MyEnum2.B;
                MyFunc(MyEnum2.B);
                break;
            default:
                break;
        }
    }
    else if (state2 == MyEnum2.B)
    {
        switch(state1)
        {
            case MyEnum1.ONE:
                state2 = MyEnum2.B;
                MyFunc(MyEnum2.B);
                break;
            case MyEnum1.THREE:
                state2 = MyEnum2.C;
                MyFunc(MyEnum2.C);
                break;
            default:
                break;                
        }
    }
    // Etcetera
}

The failure occurs on the state2 = whatever assignments. (state2 is a field, not a property)

  • 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-24T04:26:46+00:00Added an answer on May 24, 2026 at 4:26 am

    Is MyEnum.TYPE_OF_ENUM the first value in the enum, or is TYPE_OF_ENUM assigned to a integer value of 0?

    A non-initialized enum will be set to 0, so it may already match.

    Otherwise, it is much more likely that you have something else going on that you haven’t noticed yet.

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

Sidebar

Related Questions

I'm working on a new project and for some reason decided to create two
I have a django project, but for some reason basic jquery isn't working. <html>
My partner and I are working on a project using TFS. For some reason
I was working on a project that missbehaved, for some reasons no exception was
I'm working on a project involving some large XML files (from 50MB to over
I'm working on project that lets users choose some scientific authors and columnists and
I'm working on a project which includes some slightly more complex dynamic layout of
I am working on a project that requires some image processing. The front end
I am working with asp.net website project that some of pages need authentication. I
I'm currently working on project with Haskell, and have found myself some trouble. I'm

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.