Suppose, i have 4 parameters in string array.Obviously,one way to determine if any of parameter values are empty is to iterate through the array,but there is a better way to use the
Any operator.
For Example: string[] input_values = {key1,key2,key3,key4};
//now check if the arguments are empty.
if(Check_IsEmpty(input_values))
{
MessageBox.Show("values can not be empty");
return;
}
//Write a static function to check if the parameter array has any empty values.
private static bool Check_IsEmpty(string[] values)
{
return(values.Any(value => string.IsNullOrEmpty(value.Trim())));
}