I have an object with multiple strings.
Is there a way to check if one of the values is null or all values are set?
Or do I have to do it like this:
if (!string.IsNullOrWhiteSpace(object.string1) || !string.IsNullOrWhiteSpace(object.string2) || !string.IsNullOrWhiteSpace(object.string3))
{
}
You can gather all your strings into an array and then run
.Any()method:Alternatively you can use reflection (which will affect your code's performance), to scan all the strings of your object and check your condition: