it’s my first time to use this kind of action …using a loops with methods and stuff like that.
i would like to be able to loop through all parameters passed to ExcludeUsers()
say i have a few string type values ,
string user1 = "Anna";
string user2 = "Brenda";
string user3 = "John";
string user4 = "Warren";
public bool ExcludeUsers(string OmittedUser1, string OmittedUser2, string OmittedUser3)
{
string userName = "John";
// i want to loop through all parameters passed in ...
// something like this
foreach (string param in params)
{
if(userName == param)
return false;
}
return true;
}
then i want to be able using
if(ExcludeUsers(user1, user2, user3))
//do some work
then you should pass it in as OmittedUsers[], an
Arrayofstringvalues insteadThen you might want to use it like This:
you also want to consider if the
strings that you try to comparewill also (might) have capital letters,
so you should be using
.ToLower()when comparing string valuesin general ..
though it really depends if the string should be case sensitive.
for example
if the scenario is that “abc” is valid being “ABC” or “Abc” (meaning your
stringis case Insensitive)then you should, in that case the use :
if string values should be case sensitive :
which in your case seem to me that a username is case sensitive
… so you know your options.