How to check if all parameters a set

Kenneth Ballen 1 Reputation point
2021-06-16T08:49:02.343+00:00

hello i have a little problem with my project.

My project gets from the user an array with 5 places these are also parameters for a key that I generate. now I want to check before the key is generated if the user has also set all 5 parameters (array entries) and if not it should come in error. how can I do this? sorry for my bad english

C#
C#
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
10,818 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Viorel 116.5K Reputation points
    2021-06-16T10:11:24.793+00:00

    For example, in case of strings, you can use Any:

    string[] parameters = new string[5];
    
    // . . .
    
    if( parameters.Any(string.IsNullOrWhiteSpace))
    {
        // ERROR; some values are not provided
        . . . .                     
    }
    

    Show details if your parameters are different.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.