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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T16:48:41+00:00 2026-05-23T16:48:41+00:00

I have the following statement: private Enum _statusValue; What I’d really like to say

  • 0

I have the following statement:

private Enum _statusValue;

What I’d really like to say is:

private Enum _statusValue = 0;

even though I know it’s redundant. It’s just that I like to explicitly specify the initialization.

But that is not allowed.

Is there some simple way of specifying the initialization on this kind of declaration?

EDIT – Let me try again.

Here is a contrived / simplified example of what I’m doing.

using System;

namespace EnumTesting
{
   public enum EFixedPhoneUsability
   {
      UnknownValue,       // Should not occur?
      IsUsable,           // User is near the telephone
      NotUsable,          // User not near the telephone
      BeingUsed,          // Busy
      DoNotDisturb,       // This is phone physical state, not user attitude
      CallsForwarded      // This is phone physical state
   }

   public enum EMobilePhoneConnectivity
   {
      UnknownValue,       // Should not occur?
      OnNetIdle,          // I.e., usable
      OnNetBusy,          // Being used
      NoConnection        // Turned off, in elevator or tunnel or far from civilization
   }

   public class Program
   {
      public Enum StatusValue;

      static void Main(string[] args)
      {
         Program p = new Program();

         p.StatusValue = EMobilePhoneConnectivity.NoConnection;

         int i = (int) (EMobilePhoneConnectivity) p.StatusValue;

         p.StatusValue = EFixedPhoneUsability.DoNotDisturb;

         i = (int) (EFixedPhoneUsability) p.StatusValue;
      }
   }
}

So my question is, can I add a generic initializer to this statement?

      public Enum StatusValue;

SECOND EDIT:

Never mind, I have discovered the error of my ways, thanks to this posting:

How to convert from System.Enum to base integer?

The key phrase, which made me realize what I was doing wrong, is this: “enumerations are value types (and internally represented only by integer constants) while System.Enum is a reference type”.

So I do not want to say this:

private Enum _statusValue = 0;

I want to say this, which is perfectly valid:

private Enum _statusValue = null;

Thank you to those who tried to help.

  • 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-23T16:48:41+00:00Added an answer on May 23, 2026 at 4:48 pm

    My question was basically in error. I had mistakenly thought Enum (like enums) was a value type, but it is actually a reference type.

    So I do not want to say this:

    private Enum _statusValue = 0; 
    

    I want to say this, which is perfectly valid:

    private Enum _statusValue = null; 
    

    Thank you to those who tried to help.

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

Sidebar

Related Questions

I have following statement for query articles from some sections Article.all(:joins => :sections, :conditions
I have following LINQ statement and I want to rewrite it using extension methods.
I have the following statement SELECT id, descr from mytable which returns 1, 'Test1'
I have an ASP MVC view where have the following statement #if DEBUG //section
I've modified my .htaccess file to have the following statement RewriteCond $1 !^index.php$ RewriteRule
I have the following SQL-statement: SELECT DISTINCT name FROM log WHERE NOT name =
I have the following SQL Statement. I need to select the latest record for
I have the following SQL statement: Select Choose(1,Orders.Employee, Orders.Customer) as Name1, Choose(2,Orders.Employee, Orders.Customer) as
I have to following SQL Statement that I want to conver to LINQ Select
I have the following SQL statement where i'm trying to update multiple rows matching

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.