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
- CheckBoxPopupAdapter.cs
- DesignerCommandSet.cs
- FunctionCommandText.cs
- XmlCustomFormatter.cs
- WorkflowOperationInvoker.cs
- SqlCacheDependencySection.cs
- DBParameter.cs
- Mapping.cs
- DrawingContextDrawingContextWalker.cs
- FontSizeConverter.cs
- wgx_render.cs
- ViewManagerAttribute.cs
- DuplexChannelBinder.cs
- SchemaElementLookUpTable.cs
- ProfileManager.cs
- SafeNativeMethods.cs
- DayRenderEvent.cs
- ClientProxyGenerator.cs
- ServiceChannelProxy.cs
- SamlDoNotCacheCondition.cs
- AuthorizationRule.cs
- WeakEventManager.cs
- SqlTypesSchemaImporter.cs
- ImageSourceValueSerializer.cs
- SqlNotificationRequest.cs
- BuildManagerHost.cs
- MinMaxParagraphWidth.cs
- BuildProviderCollection.cs
- PresentationSource.cs
- DesignOnlyAttribute.cs
- HtmlLabelAdapter.cs
- SelectionPatternIdentifiers.cs
- GeneralTransform.cs
- DataRowIndexBuffer.cs
- DefaultBinder.cs
- KeyboardNavigation.cs
- SafeFileMapViewHandle.cs
- FrameworkTemplate.cs
- XmlILModule.cs
- SafeFileMappingHandle.cs
- ProxyManager.cs
- SymbolMethod.cs
- MatrixKeyFrameCollection.cs
- MailAddressCollection.cs
- AddInControllerImpl.cs
- HttpResponse.cs
- AuthorizationRuleCollection.cs
- XmlConverter.cs
- UnmanagedMarshal.cs
- autovalidator.cs
- ToolStripItemEventArgs.cs
- JsonXmlDataContract.cs
- RuntimeConfig.cs
- ExpandCollapsePattern.cs
- HostedElements.cs
- DataColumnMapping.cs
- ObjectParameterCollection.cs
- DynamicArgumentDesigner.xaml.cs
- SqlCachedBuffer.cs
- NegatedCellConstant.cs
- MediaElement.cs
- SafeFileMapViewHandle.cs
- AttachedAnnotationChangedEventArgs.cs
- PropertyDescriptorCollection.cs
- BaseTreeIterator.cs
- SamlAuthorityBinding.cs
- ClientSideQueueItem.cs
- ComContractElement.cs
- EncryptedXml.cs
- CodeVariableReferenceExpression.cs
- XpsResourcePolicy.cs
- CompModSwitches.cs
- TemplateControlBuildProvider.cs
- PathGradientBrush.cs
- BlurEffect.cs
- UTF8Encoding.cs
- MappingException.cs
- ProviderConnectionPoint.cs
- Deflater.cs
- XmlCharacterData.cs
- FontFaceLayoutInfo.cs
- PagesChangedEventArgs.cs
- Ipv6Element.cs
- HashHelper.cs
- OdbcParameterCollection.cs
- StrongNamePublicKeyBlob.cs
- OneWayBindingElementImporter.cs
- XmlCharCheckingWriter.cs
- PagedDataSource.cs
- FloaterBaseParaClient.cs
- DrawingAttributes.cs
- BitmapFrameDecode.cs
- TypedRowHandler.cs
- SchemaNotation.cs
- MessagePartProtectionMode.cs
- TextBoxBase.cs
- ArrayList.cs
- SignatureHelper.cs
- EndpointFilterProvider.cs
- AssemblyNameProxy.cs