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
- EventProviderWriter.cs
- DispatcherExceptionFilterEventArgs.cs
- LinkTarget.cs
- PropertyChangedEventManager.cs
- SecondaryIndexDefinition.cs
- Point.cs
- SvcMapFileLoader.cs
- Rules.cs
- ParameterExpression.cs
- ItemsPresenter.cs
- FontFaceLayoutInfo.cs
- AssemblyCache.cs
- StyleHelper.cs
- ICollection.cs
- CanonicalFontFamilyReference.cs
- SHA384.cs
- SecurityKeyIdentifierClause.cs
- XmlSchemaAny.cs
- HttpProtocolReflector.cs
- Rules.cs
- ChtmlTextWriter.cs
- Material.cs
- ModuleBuilderData.cs
- RootNamespaceAttribute.cs
- DetailsViewDeleteEventArgs.cs
- ImageSourceConverter.cs
- TypeRestriction.cs
- FocusTracker.cs
- EventMap.cs
- ReferencedAssemblyResolver.cs
- SafeFileMappingHandle.cs
- XamlStream.cs
- TickBar.cs
- DictionaryChange.cs
- ControlType.cs
- ConsoleCancelEventArgs.cs
- MenuItemBinding.cs
- WebPartVerbsEventArgs.cs
- XmlMapping.cs
- SplitterPanel.cs
- CalendarDay.cs
- JournalEntry.cs
- SoapFormatter.cs
- XmlSchemaRedefine.cs
- XmlEnumAttribute.cs
- ToolTipService.cs
- ConsoleKeyInfo.cs
- EncryptedData.cs
- base64Transforms.cs
- CustomAttributeBuilder.cs
- NodeFunctions.cs
- DescendantBaseQuery.cs
- RadioButtonFlatAdapter.cs
- DefaultMergeHelper.cs
- OutputScopeManager.cs
- ObjectItemConventionAssemblyLoader.cs
- DrawingBrush.cs
- NumericUpDownAcceleration.cs
- SymbolType.cs
- HttpValueCollection.cs
- PointUtil.cs
- mansign.cs
- HyperLinkColumn.cs
- ProxyAttribute.cs
- BuiltInPermissionSets.cs
- PopupRootAutomationPeer.cs
- BitmapEffectGeneralTransform.cs
- RightNameExpirationInfoPair.cs
- DataGridViewCellValidatingEventArgs.cs
- ForAllOperator.cs
- RuntimeCompatibilityAttribute.cs
- ButtonChrome.cs
- TargetFrameworkUtil.cs
- ListViewSortEventArgs.cs
- SQlBooleanStorage.cs
- VariantWrapper.cs
- ScalarConstant.cs
- FillErrorEventArgs.cs
- linebase.cs
- XhtmlBasicSelectionListAdapter.cs
- SaveFileDialogDesigner.cs
- PointValueSerializer.cs
- MessageQueuePermissionAttribute.cs
- PrivilegedConfigurationManager.cs
- PrtTicket_Public_Simple.cs
- AbstractExpressions.cs
- dataobject.cs
- HashHelper.cs
- TrackingDataItemValue.cs
- AssociatedControlConverter.cs
- AnnotationObservableCollection.cs
- WinFormsUtils.cs
- templategroup.cs
- HttpFileCollection.cs
- BehaviorDragDropEventArgs.cs
- XmlSignatureManifest.cs
- PlatformNotSupportedException.cs
- DrawListViewItemEventArgs.cs
- ScaleTransform3D.cs
- PropertyDescriptorGridEntry.cs