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
- ValuePattern.cs
- LineUtil.cs
- TextRangeEditTables.cs
- ClientSession.cs
- ImageConverter.cs
- GroupItemAutomationPeer.cs
- PageHandlerFactory.cs
- ExtractorMetadata.cs
- __FastResourceComparer.cs
- Select.cs
- SerializationFieldInfo.cs
- SHA256Managed.cs
- ClrPerspective.cs
- ProgressBarHighlightConverter.cs
- PrintPreviewDialog.cs
- SecurityTokenProvider.cs
- VoiceObjectToken.cs
- ReferentialConstraint.cs
- RequestCache.cs
- FieldAccessException.cs
- XmlEventCache.cs
- DataServiceOperationContext.cs
- AuthenticationSection.cs
- SQLChars.cs
- InheritedPropertyChangedEventArgs.cs
- ResourceAttributes.cs
- InputEventArgs.cs
- RsaSecurityToken.cs
- UIElement3D.cs
- VisualTreeHelper.cs
- ObjectDataSourceFilteringEventArgs.cs
- IssuanceLicense.cs
- SeparatorAutomationPeer.cs
- Transform.cs
- TextEditorThreadLocalStore.cs
- GroupQuery.cs
- EmbossBitmapEffect.cs
- XmlAttributeAttribute.cs
- PersonalizationStateInfo.cs
- PropertyToken.cs
- Monitor.cs
- GridViewSelectEventArgs.cs
- SchemaImporterExtensionElementCollection.cs
- XmlReaderSettings.cs
- LinkButton.cs
- UnhandledExceptionEventArgs.cs
- StaticExtension.cs
- EncoderParameter.cs
- XhtmlBasicLiteralTextAdapter.cs
- ChangeBlockUndoRecord.cs
- dataSvcMapFileLoader.cs
- PrintDialog.cs
- EventProviderTraceListener.cs
- EntityDataSourceValidationException.cs
- WsdlBuildProvider.cs
- Evaluator.cs
- SizeChangedInfo.cs
- ToolBarDesigner.cs
- BooleanExpr.cs
- DatagridviewDisplayedBandsData.cs
- _HTTPDateParse.cs
- HttpHeaderCollection.cs
- BrowserInteropHelper.cs
- Attributes.cs
- FixedPageStructure.cs
- Pen.cs
- handlecollector.cs
- GenericTypeParameterBuilder.cs
- AnnotationHighlightLayer.cs
- JsonServiceDocumentSerializer.cs
- ErrorStyle.cs
- CryptoProvider.cs
- DataSourceHelper.cs
- RepeatBehaviorConverter.cs
- DesignTimeTemplateParser.cs
- ThreadInterruptedException.cs
- TableLayoutPanelBehavior.cs
- Configuration.cs
- SqlDataSourceFilteringEventArgs.cs
- RSAOAEPKeyExchangeFormatter.cs
- DragDrop.cs
- ListBindableAttribute.cs
- DockProviderWrapper.cs
- ControlBuilder.cs
- SerTrace.cs
- ImageSourceValueSerializer.cs
- WindowsEditBox.cs
- MenuScrollingVisibilityConverter.cs
- ToolStripKeyboardHandlingService.cs
- StorageMappingFragment.cs
- SafeLibraryHandle.cs
- externdll.cs
- AspCompat.cs
- DataPager.cs
- InstanceKey.cs
- OleDbTransaction.cs
- Resources.Designer.cs
- FamilyCollection.cs
- DropShadowBitmapEffect.cs
- ExpressionBindings.cs