#defines

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

sorry.... hit the enter key prematurely on the other post.

From other postings I am assuming that C# #defines can not be used for bit
mask definitions as follows...

#define Value 1 0x00000001
#define Value2 0x00000002
#define Value3 0x00000004

I am assuming that I need to define such definitions as perhaps static ints
in an assembly and reference the shared assembly. Please confirm.

Also .... when referencing the assembly... is there a means to reference the
assembly relative from the IIS application directory.... so if I move the
project from IIS server to another IIS server.... all relative references
will be maintained and continue to work.

Thanks

Philip
 
Philip said:
sorry.... hit the enter key prematurely on the other post.

From other postings I am assuming that C# #defines can not be used for bit
mask definitions as follows...

#define Value 1 0x00000001
#define Value2 0x00000002
#define Value3 0x00000004

I am assuming that I need to define such definitions as perhaps static ints
in an assembly and reference the shared assembly. Please confirm.

The above would usually by done as an enumeration with the [Flags]
attribute, but you could also use

public const int Value1 = 0x00000001;
public const int Value2 = 0x00000002;

etc
Also .... when referencing the assembly... is there a means to reference the
assembly relative from the IIS application directory.... so if I move the
project from IIS server to another IIS server.... all relative references
will be maintained and continue to work.

To be honest, I don't know much about ASP.NET deployment. If you supply
all the assemblies you want to use in the same directory as the
assembly which wants to use them, I would imagine that would be fine.
 
Philip,

Use an enum instead:

[Flags]
enum MyFlags
{
Value1 = 0x00000001,
Value2 = 0x00000002,
Value3 = 0x00000004
}

Regards,
Chris.
 
Hi,
#define Value 1 0x00000001
#define Value2 0x00000002
#define Value3 0x00000004

I am assuming that I need to define such definitions as perhaps static ints
in an assembly and reference the shared assembly. Please confirm.

See the other posts regarding how to define these in C#, where to place them
depend of how you are going to use them, you can include them in an assembly
(dll) that will be used by other assemblies, maybe in your case your
solution has two projects, one is a DLL ( with the above definitions) and
the other is the web app that has a reference to the dll.
Also .... when referencing the assembly... is there a means to reference the
assembly relative from the IIS application directory.... so if I move the
project from IIS server to another IIS server.... all relative references
will be maintained and continue to work.

Thanks

Philip

If you compile your project with a reference to the shared assembly then
you don;t have any problem, you don't have to reference any assembly (in
code).

Cheers,
 
use an enum ...

enum Values
{
Value1 = 0x00000001,
Value2 = 0x00000002,
Value3 = 0x00000004
}

For ASP.NET, just drop the assembly into the bin directory directly under the virtual root.

Regards

Richard Blewett - DevelopMentor
http://staff.develop.com/richardb/weblog

nntp://news.microsoft.com/microsoft.public.dotnet.languages.csharp/<[email protected]>

sorry.... hit the enter key prematurely on the other post.

From other postings I am assuming that C# #defines can not be used for bit
mask definitions as follows...

#define Value 1 0x00000001
#define Value2 0x00000002
#define Value3 0x00000004

I am assuming that I need to define such definitions as perhaps static ints
in an assembly and reference the shared assembly. Please confirm.

Also .... when referencing the assembly... is there a means to reference the
assembly relative from the IIS application directory.... so if I move the
project from IIS server to another IIS server.... all relative references
will be maintained and continue to work.

Thanks

Philip
--
Philip

---
Incoming mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.775 / Virus Database: 522 - Release Date: 08/10/2004



[microsoft.public.dotnet.languages.csharp]
 
Back
Top