Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

How to define or declare a hex variable?

Posted on 2006-11-21
4
Medium Priority
?
1,493 Views
Last Modified: 2008-02-07
How and where do I define the followig in C#?

#define UF_ACCOUNTDISABLE 0X2
0
Comment
Question by:lapucca
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
4 Comments
 
LVL 22

Expert Comment

by:_TAD_
ID: 17990308

int UF_ACCOUNTDISABLE = 0x2;

 or

int a = 0x2F;
0
 
LVL 22

Expert Comment

by:_TAD_
ID: 17990309

int UF_ACCOUNTDISABLE = 0x2;

 or

int a = 0x2F;
0
 
LVL 22

Assisted Solution

by:_TAD_
_TAD_ earned 800 total points
ID: 17990310

int UF_ACCOUNTDISABLE = 0x2;

 or

int a = 0x2F;
0
 
LVL 7

Accepted Solution

by:
mjmarlow earned 1200 total points
ID: 17990751
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

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Article by: Ivo
C# And Nullable Types Since 2.0 C# has Nullable(T) Generic Structure. The idea behind is to allow value type objects to have null values just like reference types have. This concerns scenarios where not all data sources have values (like a databa…
Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
In response to a need for security and privacy, and to continue fostering an environment members can turn to for support, solutions, and education, Experts Exchange has created anonymous question capabilities. This new feature is available to our Pr…

636 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question