在C#中有没有写这个的简便方法:在C#中类似“在”关键字SQL速记条件
public static bool IsAllowed(int userID)
{
return (userID == Personnel.JohnDoe || userID == Personnel.JaneDoe ...);
}
像:
public static bool IsAllowed(int userID)
{
return (userID in Personnel.JohnDoe, Personnel.JaneDoe ...);
}
我知道我还可以使用开关,但大概有50个左右的函数需要我编写(将一个经典的ASP站点移植到ASP.NET上),所以我想尽可能缩短它们。
这太美了! – amrtn 2009-05-20 09:12:29