在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