SortaCore wrote:
testUser = Array.IndexOf(new string[] { "mrock", "kasante" }, Environment.UserName.ToLower()) != -1;
If you want to get a little tighter about it:
testUser = Array.Exists(new [] { "a", "b" }, t => t=="a");
First of all, you don't need string[] because the compiler can infer the array type. Second, using "Exists" makes it clearer to the reader what you're doing, especially since you're not interested in the index, you just want to know of the value exists. Lastly, the use of the predicate t => t == 'a' means you could do some fancier things if you wanted later on -- it's a more general purpose solution. (Where 'a' would actually be in your case Environment.UserName.ToLower() Marc
Day 1: Spider Database Navigator Unit Testing Succinctly