In C# is there a shorthand way to write this:
public static bool IsAllowed(int userID)
{
return (userID == Personnel.JohnDoe || userID == Personnel.JaneD
I would encapsulate the list of allowed IDs as data not code. Then it's source can be changed easily later on.
List allowedIDs = ...;
public bool IsAllowed(int userID)
{
return allowedIDs.Contains(userID);
}
If using .NET 3.5, you can use IEnumerable instead of List thanks to extension methods.
(This function shouldn't be static. See this posting: using too much static bad or good ?.)