dimanche 24 novembre 2019

C# - IF with more string variables and OR operator

I would like to check if any variable is empty or null. I have this code but it isn't working.

public HttpResponseMessage Get(string regid, int? year, string un, string ps)
{
    var isRegIDNumeric = int.TryParse(regid, out _);
    if (!isRegIDNumeric || year == null || (String.IsNullOrEmpty(un)) || (String.IsNullOrEmpty(ps)))
    {
     ...
    }

When I had only 2 variables everything was OK ...

public HttpResponseMessage Get(string regid, int? year)
{
    var isRegIDNumeric = int.TryParse(regid, out _);
    if (!isRegIDNumeric || year == null)
    {
     ...
    }

How to make functional IF with all 4 variables if any of them is null or empty?

Aucun commentaire:

Enregistrer un commentaire