我创建了以下类:
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; }
}
}
Run Code Online (Sandbox Code Playgroud)
但它会给我一个错误:在这一行
public static List<UserRole> Role { get; set; }
Run Code Online (Sandbox Code Playgroud)
错误1'Framework.Security.Current.UserRole':静态类型不能用作类型参数
这与您尝试使用该类的位置无关 - 它与您不能将静态类用作类型参数这一事实有关.鉴于您无法创建静态类的实例,如何才能List<UserRole>有用?
我强烈怀疑这些类不应该是静态类 - 为什么你想要它们呢?
(它也不清楚为什么它们应该是嵌套类,但这是另一回事.)
| 归档时间: |
|
| 查看次数: |
8012 次 |
| 最近记录: |