System.Globalization.CompareInfo.GetCompareInfo C# (CSharp) Method

GetCompareInfo() public static method

public static GetCompareInfo ( int culture ) : CompareInfo
culture int
return CompareInfo
        public static CompareInfo GetCompareInfo(int culture) {

            if (CultureTableRecord.IsCustomCultureId(culture))
            {
                // Customized culture cannot be created by the LCID.
                throw new ArgumentException(Environment.GetResourceString("Argument_CustomCultureCannotBePassedByNumber", "culture"));
            }
        
            // culture is verified to see if it is valid when CompareInfo is constructed.
            Object compInfo = GlobalizationAssembly.DefaultInstance.compareInfoCache[culture];
            if (compInfo == null) {
                lock (InternalSyncObject) {
                    //
                    // Re-check again to make sure that no one has created the CompareInfo for the culture yet before the current
                    // thread enters this sync block.
                    //
                    if ((compInfo = GlobalizationAssembly.DefaultInstance.compareInfoCache[culture]) == null) {
                        compInfo = new CompareInfo(GlobalizationAssembly.DefaultInstance, culture);
                        System.Threading.Thread.MemoryBarrier();
                        GlobalizationAssembly.DefaultInstance.compareInfoCache[culture] = compInfo;
                    }
                }
            }
            return ((CompareInfo)compInfo);
        }

Same methods

CompareInfo::GetCompareInfo ( String name ) : CompareInfo
CompareInfo::GetCompareInfo ( String name, Assembly assembly ) : CompareInfo
CompareInfo::GetCompareInfo ( int culture, Assembly assembly ) : CompareInfo

Usage Example

Beispiel #1
0
 ////////////////////////////////////////////////////////////////////////
 //
 //  GetHashCode
 //
 //  Implements Object.GetHashCode().  Returns the hash code for the
 //  SortKey.  The hash code is guaranteed to be the same for
 //  SortKey A and B where A.Equals(B) is true.
 //
 ////////////////////////////////////////////////////////////////////////
 public override int GetHashCode()
 {
     return(CompareInfo.GetCompareInfo(
                this.localeName).GetHashCodeOfString(this.m_String, this.options));
 }
All Usage Examples Of System.Globalization.CompareInfo::GetCompareInfo