Code:
/ 4.0 / 4.0 / untmp / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / clr / src / BCL / System / Collections / CaseInsensitiveComparer.cs / 1305376 / 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; using System.Diagnostics.Contracts; [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"); } Contract.EndContractBlock(); m_compareInfo = culture.CompareInfo; } public static CaseInsensitiveComparer Default { get { Contract.Ensures(Contract.Result() != null); return new CaseInsensitiveComparer(CultureInfo.CurrentCulture); } } public static CaseInsensitiveComparer DefaultInvariant { get { Contract.Ensures(Contract.Result () != null); 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.
Link Menu
This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- DigitalSignature.cs
- EntityDataSourceDesigner.cs
- WorkflowApplicationException.cs
- UIAgentAsyncEndRequest.cs
- CFStream.cs
- TextTreeNode.cs
- StyleBamlRecordReader.cs
- ForwardPositionQuery.cs
- PeerCollaboration.cs
- TagPrefixCollection.cs
- PropertyIDSet.cs
- CoreChannel.cs
- OracleDateTime.cs
- WinFormsUtils.cs
- DesignTimeParseData.cs
- Baml2006ReaderFrame.cs
- SapiRecognizer.cs
- PrintPageEvent.cs
- HostExecutionContextManager.cs
- GlyphRunDrawing.cs
- MexBindingElement.cs
- FontWeightConverter.cs
- StandardToolWindows.cs
- UnicastIPAddressInformationCollection.cs
- HtmlTableRowCollection.cs
- CurrentChangingEventArgs.cs
- PagesChangedEventArgs.cs
- StateRuntime.cs
- UnaryNode.cs
- CustomUserNameSecurityTokenAuthenticator.cs
- XmlSchemaSimpleTypeUnion.cs
- WebPartManagerDesigner.cs
- Decorator.cs
- EasingKeyFrames.cs
- TailPinnedEventArgs.cs
- HostedHttpTransportManager.cs
- VirtualPathUtility.cs
- TrustSection.cs
- StrongNameIdentityPermission.cs
- JsonWriter.cs
- ProgressBarHighlightConverter.cs
- TraceSource.cs
- BindingExpressionBase.cs
- Literal.cs
- ToolStripControlHost.cs
- ChannelHandler.cs
- ColorTransformHelper.cs
- MILUtilities.cs
- MarkupObject.cs
- Trace.cs
- NewExpression.cs
- GridViewCellAutomationPeer.cs
- ColorConvertedBitmapExtension.cs
- AliasedSlot.cs
- EntityParameterCollection.cs
- UserControlParser.cs
- Dynamic.cs
- FigureParaClient.cs
- Popup.cs
- URLString.cs
- CharacterShapingProperties.cs
- ReaderOutput.cs
- UniqueEventHelper.cs
- _StreamFramer.cs
- ThemeInfoAttribute.cs
- TextTreeFixupNode.cs
- FunctionMappingTranslator.cs
- PeerContact.cs
- DiscoveryMessageProperty.cs
- _NestedMultipleAsyncResult.cs
- WpfKnownMemberInvoker.cs
- MetadataItemEmitter.cs
- FactoryGenerator.cs
- RenderingEventArgs.cs
- ControlParameter.cs
- EncryptedXml.cs
- StyleXamlParser.cs
- NetTcpSecurity.cs
- TextOutput.cs
- EventLogPermissionEntry.cs
- AsnEncodedData.cs
- ControlCollection.cs
- EventPrivateKey.cs
- Canonicalizers.cs
- LinqDataSourceSelectEventArgs.cs
- InvokeMethodDesigner.xaml.cs
- MenuItem.cs
- BoundingRectTracker.cs
- DynamicDataExtensions.cs
- ClientRoleProvider.cs
- WebPartConnectionsCloseVerb.cs
- DbProviderSpecificTypePropertyAttribute.cs
- Control.cs
- WebPartTracker.cs
- BulletedList.cs
- SizeConverter.cs
- _ScatterGatherBuffers.cs
- TextRangeBase.cs
- BindingBase.cs
- ScriptResourceInfo.cs