Home All Groups Group Topic Archive Search About

Declaring an Enum that the whole project can use?

Author
16 Dec 2005 11:50 PM
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

Author
17 Dec 2005 12:00 AM
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?

Show quoteHide quote
"danthman" <danth***@cox.net> wrote in message
news:1134777001.919433.37600@o13g2000cwo.googlegroups.com...
> 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
>
Are all your drivers up to date? click for free checkup

Author
17 Dec 2005 1:00 AM
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
Author
17 Dec 2005 12:39 AM
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.

Show quoteHide quote
"danthman" <danth***@cox.net> wrote in message
news:1134777001.919433.37600@o13g2000cwo.googlegroups.com...
> 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
>
Author
17 Dec 2005 1:47 AM
David Jessee
you'd have to place it in a 3rd assembly that everything has a reference to

Show quoteHide quote
"danthman" wrote:

> 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
>
>

Bookmark and Share