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
- EntityConnection.cs
- Padding.cs
- CannotUnloadAppDomainException.cs
- QueryReaderSettings.cs
- SelectionGlyphBase.cs
- TextRunTypographyProperties.cs
- NameNode.cs
- StylusPlugin.cs
- CompModSwitches.cs
- HTTPNotFoundHandler.cs
- SafeSystemMetrics.cs
- ProfilePropertySettingsCollection.cs
- MultipartContentParser.cs
- Viewport3DVisual.cs
- MimeFormatter.cs
- Int16Storage.cs
- OleServicesContext.cs
- LinqDataSourceDeleteEventArgs.cs
- _AcceptOverlappedAsyncResult.cs
- _HTTPDateParse.cs
- DataReaderContainer.cs
- SendActivityEventArgs.cs
- DnsEndPoint.cs
- SpellerInterop.cs
- WindowsListViewItemCheckBox.cs
- ListChangedEventArgs.cs
- _SingleItemRequestCache.cs
- FloaterBaseParaClient.cs
- Pair.cs
- DataBindingList.cs
- DesignerCommandSet.cs
- StringReader.cs
- _IPv4Address.cs
- ChtmlCommandAdapter.cs
- XmlChildEnumerator.cs
- EventInfo.cs
- PackageStore.cs
- ComPersistableTypeElementCollection.cs
- NativeMethods.cs
- DynamicMethod.cs
- WebPartEditVerb.cs
- InputLangChangeEvent.cs
- ModuleConfigurationInfo.cs
- DesignTimeParseData.cs
- BinaryWriter.cs
- filewebrequest.cs
- GroupLabel.cs
- SafeFileMappingHandle.cs
- WindowsSidIdentity.cs
- SecureEnvironment.cs
- SmiConnection.cs
- RegexTree.cs
- SvcMapFileSerializer.cs
- DynamicEndpoint.cs
- CodeLabeledStatement.cs
- StatusBarItemAutomationPeer.cs
- ProfileServiceManager.cs
- FontSizeConverter.cs
- ProgressBarRenderer.cs
- Int32Rect.cs
- ValidationErrorEventArgs.cs
- Int32Converter.cs
- ReversePositionQuery.cs
- SelectionItemPattern.cs
- DataListItem.cs
- PageAsyncTaskManager.cs
- ServiceDescription.cs
- PrintControllerWithStatusDialog.cs
- XPathNavigatorKeyComparer.cs
- Point.cs
- PropertyRef.cs
- RightsManagementInformation.cs
- SqlClientWrapperSmiStream.cs
- ThemeDirectoryCompiler.cs
- WebPart.cs
- RawStylusInputCustomData.cs
- ActivityDesignerHelper.cs
- SQLResource.cs
- Relationship.cs
- EntityCommandDefinition.cs
- RegexNode.cs
- TrimSurroundingWhitespaceAttribute.cs
- MailMessageEventArgs.cs
- DataGridViewRowsAddedEventArgs.cs
- GroupBox.cs
- ControlCachePolicy.cs
- Label.cs
- Pair.cs
- DefaultSection.cs
- XmlSecureResolver.cs
- ScaleTransform.cs
- XmlDataProvider.cs
- SnapLine.cs
- DataContractSerializerOperationGenerator.cs
- MexBindingBindingCollectionElement.cs
- TypeUnloadedException.cs
- SafeProcessHandle.cs
- FlatButtonAppearance.cs
- SafeEventLogWriteHandle.cs
- ListControl.cs