Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7775859
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T17:43:53+00:00 2026-06-01T17:43:53+00:00

Shamed by this simple question. For some reason, I want to put all asp.net

  • 0

Shamed by this simple question. For some reason, I want to put all asp.net URLs in an enum. But I got an error: identifer expected

My code:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Admin.Code
{
    public enum url
    {
       /_layouts/Admin/test1.aspx,
       /_layouts/Admin/test2.aspx,
       /_layouts/Admin/test3.aspx
    }

    class AdminUrlSettings
    {
    }
}

Thanks.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T17:43:54+00:00Added an answer on June 1, 2026 at 5:43 pm

    Identifiers in C# can’t contain / characters. They are limited to underscores, letters and numbers (and possibly a @ prefix). To fix this you need to make the enum values valid C# identifiers

    enum url {
      test1,
      test2,
      test3
    }
    

    Later turning these into an actual valid url can be done with a switch statement over the value

    public static string GetRelativeUrl(url u) {
      switch (u) {
        case url.test1:
          return "/_layouts/Admin/test1.aspx";
        case url.test2:
          return "/_layouts/Admin/test2.aspx";
        case url.test3:
          return "/_layouts/Admin/test3.aspx";
        default: 
          // Handle bad URL, possibly throw
          throw new Exception();
      }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This question goes beoynd just programming, but I'd like to get some input on
This question might appear very simple, but i haven't found an answer yet, so
This question pops up in my mind form time to time, but since the
Sorry, simple question but it is something that is always confused me when speaking
I know that this question has been asked previously, but before you give me
Well, this is not at all an optimization question. I am writing a (for
I have created this simple program to learn shared_ptr using namespace std; #define Yes
This simple example fails to compile in VS2K8: io_service io2; shared_ptr<asio::deadline_timer> dt(make_shared<asio::deadline_timer>(io2, posix_time::seconds(20))); As
I have a method written in VB.NET. It looks like this: Shared Sub SomeMethod(ByVal
This question is mainly aimed at shared libraries (.so files) compiled for Linux platforms.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.