Solved

How to define or declare a hex variable?

Posted on 2006-11-21
4
1,366 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
  • 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 200 total points
ID: 17990310

int UF_ACCOUNTDISABLE = 0x2;

 or

int a = 0x2F;
0
 
LVL 7

Accepted Solution

by:
mjmarlow earned 300 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
How to use xmlReader and idatareader  ? 4 55
XAML: Layout 8 25
C#.NET and microsoft certification. 3 30
Web Form VB.Net  import CSV 4 24
Summary: Persistence is the capability of an application to store the state of objects and recover it when necessary. This article compares the two common types of serialization in aspects of data access, readability, and runtime cost. A ready-to…
This article introduced a TextBox that supports transparent background.   Introduction TextBox is the most widely used control component in GUI design. Most GUI controls do not support transparent background and more or less do not have the…
Along with being a a promotional video for my three-day Annielytics Dashboard Seminor, this Micro Tutorial is an intro to Google Analytics API data.
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…

911 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now