problem putting enum in page_load

T

tony collier

I have the following in one of my .aspx pages:

.....

<script runat="server">

enum bookstores

{
Amazon,
Blackwells,
ComputerManuals,
ComputerBooks
};

void Page_Load(Object sender, EventArgs e)

{


// DECLARE VARIABLES

.....

}

</script>


can someone tell me why the above works fine, yet if i put the enum
declaration IN Page_Load function above // DECLARE VARIABLES I get:


Compiler Error Message: CS1513: } expected

Line 10: void Page_Load(Object sender, EventArgs e)
Line 11:
Line 12: {
Line 13:
Line 14: enum bookstores


error on line 12 ?


Thanks to anyone who can throw light on this
 
T

Teemu Keiski

Enum is one value type in .NET (inherits from System.Enum). Types are
declared separately of their usage meaning you can consume / use the type
inside the method, but you declare it outside the method, just as class or
any other type would be. They are declared at namespace level and used as
class/member level.
 

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

Forum statistics

Threads
473,769
Messages
2,569,581
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top