Declaring an Enum that the whole project can use?

D

danthman

I've written an enumeration object, and now I want all the web forms
and web controls in my project to be able to use it. Is this possible?
How can it be done?

Thanks,

-Dan
 
P

Peter Rilling

Sure. Make it public and outside of all other classes. Maybe put it in its
own file or something. Why do you think you cannot?
 
A

Andrew Robinson

Assuming you are using 2.0 you can put the following in your App_Code folder
inside of a .cs file:

using System;

public enum NobelGases { Helium, Neon, Argon, Krypton, Xenon, Radon }



I think that technically the 'using System' is not required but it makes the
code more readable in that you know where you are and most people look for a
using section at the top of their file. Do the same with VB.NET but change
where appropriate.
 
D

danthman

I put the following in the default.aspx.vb file before (i.e., outside)
the class definition:

-----
Public Enum AccessModeEnum As Byte
NoAcess
SurveyAcess
FullAcess
End Enum
-----

Then I attempted to refer to it in another aspx.vb module with:

-----
If AccessModeByte = AccessModeEnum.NoAcess Then
,,,
End If
-----

And I get a squiggly line under AccessModeEnum with the error message:

"AccessEnum is not declared"

So, not to be a smart ass, but that's what makes me think I cannot :)

Thx,

-Dan
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,581
Members
45,056
Latest member
GlycogenSupporthealth

Latest Threads

Top