Should I return true or false if both of the IP address strings are empty? I am validating two IP addresses. I simply wrote a peice of code like 

if(string.IsNullOrEmpty(ip1) &amp;&amp; string.IsNullOrEmpty(ip2) 
  return true;


But is this logically correct? What should we done with empty strings? If both are empty strings, is it okay to return true?

May be a complete code snipet can give better insight.

public static bool IsIPAddressMatching(string ipAddressA, string ipAddressB)
        {
            try
            {
                if(string.IsNullOrEmpty(ipAddressA) || string.IsNullOrEmpty(ipAddressB))
                    return true;
                var address1 = IPAddress.Parse(ipAddressA);
                var address2 = IPAddress.Parse(ipAddressB);

                if (address1.AddressFamily == address2.AddressFamily)
                    return (address1.Equals(address2));

               // some code here to check mapped IP addresses

            }
            catch (Exception)
            {
                return false;
            }
        }
From the IP validation point of view null or empty IP addresses are exceptional actions so you can not say that two null or empty strings are the same IP addresses becouse they aren't IP addresses and sometimes not even strings.

And you don't have to sorrund the logic with try-catch block becouse it will eat usefull information when things will get ugly. If you don't want to deal with parsing exception then use IPAddress.TryParse it will be faster becouse throwing an exception is always a heavy weight stuff (check it with profiler).

public static bool IsIPAddressMatching(string ipAddressA, string ipAddressB)
{
    if (ipAddressA == null)
    {
        throw new ArgumentNullException("ipAddressA");
    }
    if (ipAddressB == null)
    {
        throw new ArgumentNullException("ipAddressB");
    }

    if (string.IsNullOrEmpty(ipAddressA))
    {
        throw new ArgumentException("ipAddressA cannot be an empty string", "ipAddressA");
    }
    if (string.IsNullOrEmpty(ipAddressB))
    {
        throw new ArgumentException("ipAddressB cannot be an empty string", "ipAddressB");
    }

    var address1 = IPAddress.Parse(ipAddressA);
    var address2 = IPAddress.Parse(ipAddressB);

    if (address1.AddressFamily == address2.AddressFamily)
    {
        return (address1.Equals(address2));
    }

   // some code here to check mapped IP addresses

   return ...
}