-
Notifications
You must be signed in to change notification settings - Fork 4.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Multiple string null and empty check #108565
Comments
I couldn't figure out the best area label to add to this issue. If you have write-permissions please help me learn by adding exactly one area label. |
I couldn't figure out the best area label to add to this issue. If you have write-permissions please help me learn by adding exactly one area label. |
Seems easy enough to implement in the application: public class C {
public static bool IsAnyNullOrEmpty(params string?[] strings) {
foreach (string? s in strings) {
if (string.IsNullOrEmpty(s)) {
return true;
}
}
return false;
}
} This costs a I don't remember ever needing that kind of multiple IsNullOrEmpty check in an application. If it is for detecting invalid inputs, then the error message would typically explain which of the strings is invalid, like in ArgumentException.ThrowIfNullOrEmpty. If the strings are in properties rather than parameters, then OptionsValidatorAttribute may be useful. |
I know we have different approaches for this. but as a suggestion, it would be nice to have such feature in future. |
This is an API request, belongs in https://github.com/dotnet/runtime |
Tagging subscribers to this area: @dotnet/area-system-runtime |
It is not a bug. It is a suggestion or feature request
I want to use
IsNullOrEmpty()
here:if (!string.IsNullOrEmpty(FirstName) && !string.IsNullOrEmpty(LastName) && !string.IsNullOrEmpty(Mobile))
It is not nice to do like this.
It would be nice to have something like
IsNullOrEmpty(string,string,string,string...)
something like
Path.Combine()
. As you know it accepts some string and make the path. so, we could have 1-5 string inIsNullOrEmpty
method, too.thanks
The text was updated successfully, but these errors were encountered: