コード例 #1
0
ファイル: CountryIso3166.cs プロジェクト: rapidcore/rapidcore
        /// <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));
        }
コード例 #2
0
ファイル: RestCountries.cs プロジェクト: StrubT/PlayGround
 public override bool Equals(object obj) => obj != null && GetType().Equals(obj.GetType()) && CodeAlpha3.Equals(((Country)obj).CodeAlpha3);
コード例 #3
0
ファイル: RestCountries.cs プロジェクト: StrubT/PlayGround
 public override int GetHashCode() => 13 + CodeAlpha3.GetHashCode();