problem putting enum in page_load

Discussion in 'ASP .Net' started by tony collier, Jan 21, 2004.

  1. tony collier

    tony collier Guest

    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
     
    tony collier, Jan 21, 2004
    #1
    1. Advertising

  2. tony collier

    Teemu Keiski Guest

    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" <> wrote in message
    news:Xns9477C833E8015melakkahotmailcom@140.99.99.130...
    >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
     
    Teemu Keiski, Jan 22, 2004
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. bminder
    Replies:
    1
    Views:
    2,183
    nfedin
    Feb 23, 2004
  2. z. f.
    Replies:
    0
    Views:
    563
    z. f.
    Oct 19, 2004
  3. Saurabh
    Replies:
    6
    Views:
    4,549
    Chris Smith
    May 30, 2004
  4. rockdale
    Replies:
    1
    Views:
    665
    =?Utf-8?B?UGV0ZXIgQnJvbWJlcmcgW0MjIE1WUF0=?=
    Nov 16, 2006
  5. Sunfire
    Replies:
    2
    Views:
    654
    Sunfire
    Nov 5, 2007
Loading...

Share This Page