/// <summary> /// Does this country have the given country code. /// /// If given <c>null</c>, <c>false</c> is returned. /// </summary> /// <param name="alpha2OrAlpha3OrNumeric">Country code to check as either alpha-2, alpha-3 or numeric (null is handled)</param> public virtual bool Is(string alpha2OrAlpha3OrNumeric) { if (string.IsNullOrEmpty(alpha2OrAlpha3OrNumeric)) { return(false); } if (int.TryParse(alpha2OrAlpha3OrNumeric, out int numeric)) { return(numeric == CodeNumeric); } var uppered = alpha2OrAlpha3OrNumeric.ToUpper(); return(CodeAlpha2.Equals(uppered) || CodeAlpha3.Equals(uppered)); }
public override bool Equals(object obj) => obj != null && GetType().Equals(obj.GetType()) && CodeAlpha3.Equals(((Country)obj).CodeAlpha3);