469,927 Members | 1,672 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,927 developers. It's quick & easy.

problem putting enum in page_load

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
Nov 18 '05 #1
2 1144
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.

--
Teemu Keiski
MCP, Microsoft MVP (ASP.NET), AspInsiders member
ASP.NET Forum Moderator, AspAlliance Columnist
"tony collier" <me*****@hotmail.com> wrote in message
news:Xn*******************************@140.99.99.1 30...
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

Nov 18 '05 #2
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.

--
Teemu Keiski
MCP, Microsoft MVP (ASP.NET), AspInsiders member
ASP.NET Forum Moderator, AspAlliance Columnist
"tony collier" <me*****@hotmail.com> wrote in message
news:Xn*******************************@140.99.99.1 30...
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

Nov 18 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

5 posts views Thread by Bob N | last post: by
2 posts views Thread by wapsiii | last post: by
reply views Thread by Phil C. | last post: by
2 posts views Thread by Mike Collins | last post: by
8 posts views Thread by CK | last post: by
3 posts views Thread by Chris Lincoln | last post: by
1 post views Thread by tshad | last post: by
10 posts views Thread by oktayarslan | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.