Code:
/ DotNET / DotNET / 8.0 / untmp / whidbey / REDBITS / 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); } } }
Link Menu

This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- LabelLiteral.cs
- TreeViewBindingsEditorForm.cs
- DataSourceCache.cs
- MembershipSection.cs
- FlowDocumentFormatter.cs
- NumberAction.cs
- AttributeCollection.cs
- SqlException.cs
- LinqDataSourceUpdateEventArgs.cs
- ConfigXmlAttribute.cs
- CommandValueSerializer.cs
- XLinq.cs
- HyperLinkField.cs
- LogRestartAreaEnumerator.cs
- CodeParameterDeclarationExpressionCollection.cs
- ClientRoleProvider.cs
- DBCommand.cs
- ContextMenuAutomationPeer.cs
- TableAdapterManagerNameHandler.cs
- LoginDesigner.cs
- PeerNameResolver.cs
- ObjectStateEntryDbUpdatableDataRecord.cs
- ProtocolsInstallComponent.cs
- WindowsGraphicsWrapper.cs
- IndentTextWriter.cs
- ProviderConnectionPoint.cs
- Marshal.cs
- MultiAsyncResult.cs
- WorkflowInvoker.cs
- SafeNativeMethodsCLR.cs
- HttpValueCollection.cs
- input.cs
- SafeSecurityHelper.cs
- XmlTypeAttribute.cs
- NumberSubstitution.cs
- BitmapImage.cs
- ArgIterator.cs
- CalendarDateRangeChangingEventArgs.cs
- PartialList.cs
- NavigationExpr.cs
- UserValidatedEventArgs.cs
- Triplet.cs
- listviewsubitemcollectioneditor.cs
- BamlRecords.cs
- Repeater.cs
- NamespaceListProperty.cs
- Matrix3DConverter.cs
- AmbiguousMatchException.cs
- SevenBitStream.cs
- XPathEmptyIterator.cs
- SecurityIdentifierElementCollection.cs
- LogStore.cs
- LinqDataSourceDisposeEventArgs.cs
- ProxyWebPart.cs
- DataGridViewComboBoxEditingControl.cs
- AnnotationStore.cs
- SRGSCompiler.cs
- CodePrimitiveExpression.cs
- ContextStaticAttribute.cs
- BuildManager.cs
- TextElementEditingBehaviorAttribute.cs
- ProcessHostServerConfig.cs
- wpf-etw.cs
- ServiceDiscoveryBehavior.cs
- BidPrivateBase.cs
- AssemblyBuilder.cs
- _Rfc2616CacheValidators.cs
- LinearKeyFrames.cs
- PipelineModuleStepContainer.cs
- UIElementPropertyUndoUnit.cs
- BevelBitmapEffect.cs
- TableRowCollection.cs
- LoadItemsEventArgs.cs
- CharacterHit.cs
- ListenerServiceInstallComponent.cs
- SelectionRangeConverter.cs
- GcSettings.cs
- MaterialGroup.cs
- CacheForPrimitiveTypes.cs
- IteratorDescriptor.cs
- OracleBoolean.cs
- FloaterParagraph.cs
- Hash.cs
- TabletCollection.cs
- AVElementHelper.cs
- EntityDataSourceColumn.cs
- XmlSerializationWriter.cs
- ElementNotAvailableException.cs
- ListenerUnsafeNativeMethods.cs
- CompositionTarget.cs
- FormViewPagerRow.cs
- ObjectPersistData.cs
- ContentFileHelper.cs
- ClientSession.cs
- ForceCopyBuildProvider.cs
- DesigntimeLicenseContextSerializer.cs
- _ReceiveMessageOverlappedAsyncResult.cs
- CodeTypeMember.cs
- MSG.cs
- SByteStorage.cs