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.
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# identifiersLater turning these into an actual valid url can be done with a switch statement over the value