Code:
/ Net / Net / 3.5.50727.3053 / DEVDIV / depot / DevDiv / releases / whidbey / netfxsp / 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. // // ==--== /*============================================================ ** ** 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.
Link Menu
This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- ContextMarshalException.cs
- FocusChangedEventArgs.cs
- StatusBarPanel.cs
- Double.cs
- GridViewCellAutomationPeer.cs
- TypeSemantics.cs
- ReliableInputConnection.cs
- Pair.cs
- FileLevelControlBuilderAttribute.cs
- StylusPointProperties.cs
- CallbackHandler.cs
- XmlSchema.cs
- GroupItem.cs
- StreamHelper.cs
- BinaryWriter.cs
- WebBrowserUriTypeConverter.cs
- COM2ExtendedUITypeEditor.cs
- ZoneIdentityPermission.cs
- EventLogger.cs
- ObfuscationAttribute.cs
- UserControlDesigner.cs
- XmlSchemaElement.cs
- EventTrigger.cs
- ContentFilePart.cs
- AffineTransform3D.cs
- ListItemConverter.cs
- MsmqIntegrationBinding.cs
- MULTI_QI.cs
- FormViewDeleteEventArgs.cs
- AudienceUriMode.cs
- BaseAppDomainProtocolHandler.cs
- ServicesUtilities.cs
- AbstractSvcMapFileLoader.cs
- WebResourceAttribute.cs
- ByteArrayHelperWithString.cs
- OfTypeExpression.cs
- IPEndPointCollection.cs
- SiteMapNode.cs
- CacheMemory.cs
- Vector3DIndependentAnimationStorage.cs
- RightsManagementManager.cs
- NativeMethods.cs
- CryptoConfig.cs
- XmlUrlResolver.cs
- CapabilitiesUse.cs
- PopupRootAutomationPeer.cs
- Rotation3D.cs
- FormsAuthentication.cs
- GridItemCollection.cs
- ComponentChangedEvent.cs
- Profiler.cs
- VolatileResourceManager.cs
- Thread.cs
- DecoderFallback.cs
- XsltException.cs
- StopStoryboard.cs
- FocusWithinProperty.cs
- XmlSignatureProperties.cs
- AbstractDataSvcMapFileLoader.cs
- RegisteredExpandoAttribute.cs
- XmlSchemaObjectTable.cs
- AttributeCollection.cs
- GenericWebPart.cs
- ExpressionBuilderCollection.cs
- DataStreamFromComStream.cs
- WindowsUpDown.cs
- CreateUserErrorEventArgs.cs
- PathStreamGeometryContext.cs
- InstanceContextManager.cs
- HttpWriter.cs
- CommandHelpers.cs
- DrawListViewColumnHeaderEventArgs.cs
- DuplexChannelFactory.cs
- CssClassPropertyAttribute.cs
- ComponentResourceKey.cs
- NavigateEvent.cs
- OpenTypeMethods.cs
- DateTimeOffset.cs
- TemplateBindingExpression.cs
- SqlDataSourceCache.cs
- MenuItem.cs
- safex509handles.cs
- SqlMultiplexer.cs
- AppearanceEditorPart.cs
- UIPermission.cs
- HierarchicalDataBoundControlAdapter.cs
- DesignerObjectListAdapter.cs
- RequestCachingSection.cs
- ILGenerator.cs
- CornerRadius.cs
- _Connection.cs
- BitmapEffectDrawingContent.cs
- HtmlFormParameterWriter.cs
- ChildrenQuery.cs
- XPathItem.cs
- ProjectionPathBuilder.cs
- ListViewAutomationPeer.cs
- IConvertible.cs
- DescendentsWalkerBase.cs
- CollectionEditorDialog.cs