?
Solved

How to define or declare a hex variable?

Posted on 2006-11-21
4
Medium Priority
?
1,438 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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

Introduction Although it is an old technology, serial ports are still being used by many hardware manufacturers. If you develop applications in C#, Microsoft .NET framework has SerialPort class to communicate with the serial ports.  I needed to…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…

801 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