Solved

How to define or declare a hex variable?

Posted on 2006-11-21
4
1,373 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

Does Powershell have you tied up in knots?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

Question has a verified solution.

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

In order to hide the "ugly" records selectors (triangles) in the rowheaders, here are some suggestions. Microsoft doesn't have a direct method/property to do it. You can only hide the rowheader column. First solution, the easy way The first sol…
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!
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

809 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