Code:
/ FX-1434 / FX-1434 / 1.0 / untmp / whidbey / REDBITS / 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); } } }
Link Menu
This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- ConfigurationFileMap.cs
- MetadataItemSerializer.cs
- AuthenticateEventArgs.cs
- XamlReader.cs
- PropertyNames.cs
- CodeTypeParameterCollection.cs
- OleDbParameter.cs
- XmlAttributeAttribute.cs
- TableAdapterManagerGenerator.cs
- _emptywebproxy.cs
- SiteMapSection.cs
- ExceptionRoutedEventArgs.cs
- InvalidContentTypeException.cs
- DataContractJsonSerializer.cs
- SystemWebSectionGroup.cs
- ThemeDirectoryCompiler.cs
- VisualTreeHelper.cs
- ToolStripSettings.cs
- JulianCalendar.cs
- ReaderOutput.cs
- XmlQualifiedName.cs
- StringUtil.cs
- ConnectionPoint.cs
- Int64Storage.cs
- FontDialog.cs
- TextEditorTyping.cs
- Registration.cs
- StringBuilder.cs
- TextSelectionProcessor.cs
- Path.cs
- ScriptControlDescriptor.cs
- _NestedSingleAsyncResult.cs
- Panel.cs
- ExpressionWriter.cs
- DbDataAdapter.cs
- ApplicationHost.cs
- SqlCommand.cs
- TypeSemantics.cs
- ToolStripRendererSwitcher.cs
- TrueReadOnlyCollection.cs
- TreeViewItemAutomationPeer.cs
- DataBinder.cs
- HttpInputStream.cs
- X509CertificateCollection.cs
- ImplicitInputBrush.cs
- Accessible.cs
- FixedLineResult.cs
- PropertyKey.cs
- SystemInfo.cs
- MULTI_QI.cs
- XPathQilFactory.cs
- WindowInteractionStateTracker.cs
- ObjectStateManagerMetadata.cs
- EdgeProfileValidation.cs
- ExplicitDiscriminatorMap.cs
- MailWriter.cs
- ComponentManagerBroker.cs
- TrustManagerMoreInformation.cs
- XamlReaderHelper.cs
- LogArchiveSnapshot.cs
- TextBoxView.cs
- Encoder.cs
- DataGridViewSortCompareEventArgs.cs
- SignatureHelper.cs
- RenderOptions.cs
- OutputCacheProfile.cs
- CustomAttributeFormatException.cs
- BindingSourceDesigner.cs
- BindingNavigator.cs
- FactoryGenerator.cs
- ImageListStreamer.cs
- XmlDsigSep2000.cs
- HideDisabledControlAdapter.cs
- IPEndPointCollection.cs
- CodeTypeReferenceExpression.cs
- StreamInfo.cs
- DeviceContexts.cs
- EmptyQuery.cs
- SkewTransform.cs
- Parameter.cs
- GridViewPageEventArgs.cs
- KeyNotFoundException.cs
- Bits.cs
- BamlTreeUpdater.cs
- DataBindingCollection.cs
- LayoutEditorPart.cs
- TemplatePartAttribute.cs
- CompatibleComparer.cs
- EntityAdapter.cs
- XhtmlConformanceSection.cs
- TraceHandlerErrorFormatter.cs
- TextBounds.cs
- activationcontext.cs
- LinearKeyFrames.cs
- DispatcherTimer.cs
- AudienceUriMode.cs
- MessagePartProtectionMode.cs
- ToolStripControlHost.cs
- SqlBinder.cs
- MaterialCollection.cs