How to define or declare a hex variable?

How and where do I define the followig in C#?

#define UF_ACCOUNTDISABLE 0X2
lapuccaAsked:
Who is Participating?
 
mjmarlowConnect With a Mentor Commented:
C# does not support #define constants.  Instead you create const variable.  The const variables are resolved at compile time.  You can define them anywhere.  


// Example: Create a class GlobalConstants and define a public const variable inside to create global constants

using System;
using System.Collections.Generic;
using System.Text;

namespace BusinessLayer
{
    public class GlobalConstants
    {
        public  const int UF_ACCOUNTDISABLE = 0x2;
    }
}

Reference it in other classes using
...
Console.WriteLine(BusinessLayer.GlobalConstants.ACCOUNTDISABLE);

When this is compiled, the compiler will replace the above statement with:
Console.WriteLine(0x2);

- Mark
0
 
_TAD_Commented:

int UF_ACCOUNTDISABLE = 0x2;

 or

int a = 0x2F;
0
 
_TAD_Commented:

int UF_ACCOUNTDISABLE = 0x2;

 or

int a = 0x2F;
0
 
_TAD_Connect With a Mentor Commented:

int UF_ACCOUNTDISABLE = 0x2;

 or

int a = 0x2F;
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.