I have created following class:
public static class Current
{
public static class User
{
public static int UserID { get; set; }
public static string UserName { get; set; }
public static List<UserRole> Role { get; set; }
}
public static class UserRole
{
public static int RoleID { get; set; }
public static string RoleName { get; set; }
}
}
But it will gives me an error: in this line
public static List<UserRole> Role { get; set; }
Error 1 ‘Framework.Security.Current.UserRole’: static types cannot be used as type arguments
This has nothing to do with where you’re trying to use the class – it has everything to do with the fact that you can’t use a static class as a type argument. Given that you can’t create an instance of a static class, how could a
List<UserRole>ever be useful?I strongly suspect that those classes shouldn’t be static classes to start with – why on earth would you want them to be?
(It’s also not clear why they should be nested classes, but that’s a different matter.)