Code:
/ FXUpdate3074 / FXUpdate3074 / 1.1 / untmp / whidbey / QFE / ndp / clr / src / BCL / System / Collections / CaseInsensitiveComparer.cs / 1 / CaseInsensitiveComparer.cs
// ==++== // // Copyright (c) Microsoft Corporation. All rights reserved. // // ==--== /*============================================================ ** ** Class: CaseInsensitiveComparer ** ** ** ============================================================*/ namespace System.Collections { //This class does not contain members and does not need to be serializable using System; using System.Collections; using System.Globalization; [Serializable] [System.Runtime.InteropServices.ComVisible(true)] public class CaseInsensitiveComparer : IComparer { private CompareInfo m_compareInfo; private static CaseInsensitiveComparer m_InvariantCaseInsensitiveComparer; public CaseInsensitiveComparer() { m_compareInfo = CultureInfo.CurrentCulture.CompareInfo; } public CaseInsensitiveComparer(CultureInfo culture) { if (culture==null) { throw new ArgumentNullException("culture"); } m_compareInfo = culture.CompareInfo; } public static CaseInsensitiveComparer Default { get { return new CaseInsensitiveComparer(CultureInfo.CurrentCulture); } } public static CaseInsensitiveComparer DefaultInvariant { get { if (m_InvariantCaseInsensitiveComparer == null) { m_InvariantCaseInsensitiveComparer = new CaseInsensitiveComparer(CultureInfo.InvariantCulture); } return m_InvariantCaseInsensitiveComparer; } } // Behaves exactly like Comparer.Default.Compare except that the comparison is case insensitive // Compares two Objects by calling CompareTo. If a == // b,0 is returned. If a implements // IComparable, a.CompareTo(b) is returned. If a // doesn't implement IComparable and b does, // -(b.CompareTo(a)) is returned, otherwise an // exception is thrown. // public int Compare(Object a, Object b) { String sa = a as String; String sb = b as String; if (sa != null && sb != null) return m_compareInfo.Compare(sa, sb, CompareOptions.IgnoreCase); else return Comparer.Default.Compare(a,b); } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. // Copyright (c) Microsoft Corporation. All rights reserved.
Link Menu
This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- UIntPtr.cs
- XmlAttributeOverrides.cs
- StandardOleMarshalObject.cs
- ClipboardData.cs
- AutomationPatternInfo.cs
- CodeStatementCollection.cs
- DiscoveryMessageSequenceCD1.cs
- _SslState.cs
- StopStoryboard.cs
- SchemaTableColumn.cs
- CollaborationHelperFunctions.cs
- DbConnectionPool.cs
- RecordManager.cs
- Closure.cs
- WeakReferenceList.cs
- WebBrowserNavigatingEventHandler.cs
- MetadataItem_Static.cs
- Encoding.cs
- SqlFunctionAttribute.cs
- UrlMappingsModule.cs
- CustomCredentialPolicy.cs
- mediapermission.cs
- HandlerFactoryCache.cs
- NetworkInformationPermission.cs
- DbProviderSpecificTypePropertyAttribute.cs
- QueueProcessor.cs
- TypeUtil.cs
- CmsInterop.cs
- RtfFormatStack.cs
- XmlSchemaAnnotated.cs
- DependencyPropertyHelper.cs
- EncoderBestFitFallback.cs
- HandlerMappingMemo.cs
- DelegateTypeInfo.cs
- TemplateBindingExpressionConverter.cs
- PeerEndPoint.cs
- XmlDownloadManager.cs
- RTLAwareMessageBox.cs
- DataKeyArray.cs
- MsmqOutputChannel.cs
- FrameworkTextComposition.cs
- DataGridViewLayoutData.cs
- HtmlGenericControl.cs
- MailWriter.cs
- StrokeCollectionConverter.cs
- FieldAccessException.cs
- TransferRequestHandler.cs
- ProviderSettings.cs
- ToolBarButtonDesigner.cs
- GrammarBuilderRuleRef.cs
- AsnEncodedData.cs
- DiscoveryClientChannelBase.cs
- CompositionTarget.cs
- HostUtils.cs
- WinFormsUtils.cs
- MissingManifestResourceException.cs
- RawStylusSystemGestureInputReport.cs
- safemediahandle.cs
- RawStylusActions.cs
- SelectedDatesCollection.cs
- PopupEventArgs.cs
- MenuBase.cs
- WebBrowserSiteBase.cs
- XamlPathDataSerializer.cs
- ResourceSetExpression.cs
- SafeThreadHandle.cs
- WindowsGraphicsWrapper.cs
- CharacterHit.cs
- CRYPTPROTECT_PROMPTSTRUCT.cs
- ViewManager.cs
- NavigationHelper.cs
- WindowsComboBox.cs
- DoWorkEventArgs.cs
- EncryptedXml.cs
- storagemappingitemcollection.viewdictionary.cs
- UnsafeNativeMethods.cs
- ColorKeyFrameCollection.cs
- SingleAnimation.cs
- PtsHost.cs
- CryptoProvider.cs
- wmiutil.cs
- Stylus.cs
- EqualityComparer.cs
- BitmapMetadataEnumerator.cs
- CloseSequenceResponse.cs
- ZipIOCentralDirectoryFileHeader.cs
- WindowsPrincipal.cs
- SerialErrors.cs
- ConfigurationSchemaErrors.cs
- AttributeCollection.cs
- safemediahandle.cs
- GridViewEditEventArgs.cs
- ScriptResourceInfo.cs
- ConvertEvent.cs
- X509IssuerSerialKeyIdentifierClause.cs
- VisualTreeHelper.cs
- EnumerationRangeValidationUtil.cs
- StringDictionaryCodeDomSerializer.cs
- DataPagerFieldCollection.cs
- DesignerSerializationVisibilityAttribute.cs