Code:
/ Dotnetfx_Win7_3.5.1 / Dotnetfx_Win7_3.5.1 / 3.5.1 / DEVDIV / depot / DevDiv / releases / whidbey / NetFXspW7 / 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
- TextTreeNode.cs
- AssemblyAttributes.cs
- DBCommand.cs
- CodeIndexerExpression.cs
- SystemTcpConnection.cs
- ResourceProperty.cs
- OpCodes.cs
- XamlSerializerUtil.cs
- EndpointInfo.cs
- IndentTextWriter.cs
- EasingKeyFrames.cs
- HttpInputStream.cs
- XmlWrappingReader.cs
- Region.cs
- rsa.cs
- TextParaLineResult.cs
- SafeEventLogReadHandle.cs
- XsltContext.cs
- TypeHelper.cs
- EntitySetBaseCollection.cs
- Selection.cs
- SqlTriggerAttribute.cs
- XmlDownloadManager.cs
- SizeF.cs
- GacUtil.cs
- SessionSwitchEventArgs.cs
- ConnectionPoolManager.cs
- ClientBuildManager.cs
- AssemblyNameProxy.cs
- TypeHelpers.cs
- ComponentManagerBroker.cs
- GC.cs
- XmlDataSource.cs
- InfoCardClaimCollection.cs
- WebHttpSecurityElement.cs
- DependencyObjectPropertyDescriptor.cs
- ListViewPagedDataSource.cs
- PersistChildrenAttribute.cs
- DataContractAttribute.cs
- DesignTimeType.cs
- ItemsControl.cs
- SortableBindingList.cs
- XmlEncodedRawTextWriter.cs
- EventDescriptor.cs
- Annotation.cs
- RemoteWebConfigurationHostStream.cs
- ACL.cs
- TraceInternal.cs
- MetabaseServerConfig.cs
- ClaimSet.cs
- _ListenerRequestStream.cs
- XmlnsCompatibleWithAttribute.cs
- DataListItem.cs
- cookieexception.cs
- RightsManagementErrorHandler.cs
- Propagator.JoinPropagator.JoinPredicateVisitor.cs
- IProvider.cs
- RTLAwareMessageBox.cs
- NativeMethods.cs
- StrokeNodeData.cs
- FrameworkContentElement.cs
- ResourceExpressionBuilder.cs
- ChooseAction.cs
- MgmtResManager.cs
- FontFamilyValueSerializer.cs
- MarginCollapsingState.cs
- HtmlSelect.cs
- DateTimePicker.cs
- Color.cs
- DSASignatureDeformatter.cs
- EntityModelSchemaGenerator.cs
- StoreItemCollection.Loader.cs
- DataSetMappper.cs
- BaseCodePageEncoding.cs
- connectionpool.cs
- XslTransform.cs
- RepeatInfo.cs
- IndentedWriter.cs
- AppSecurityManager.cs
- TransactionException.cs
- TableCell.cs
- IgnoreSection.cs
- OracleCommandBuilder.cs
- AffineTransform3D.cs
- PtsHelper.cs
- XmlReaderSettings.cs
- StateBag.cs
- DataBindingCollection.cs
- coordinatorfactory.cs
- JpegBitmapDecoder.cs
- DataProviderNameConverter.cs
- CallInfo.cs
- SqlTypeConverter.cs
- ToolboxComponentsCreatingEventArgs.cs
- FilteredXmlReader.cs
- MultiPropertyDescriptorGridEntry.cs
- BrushValueSerializer.cs
- InternalEnumValidatorAttribute.cs
- Parallel.cs
- ArrangedElementCollection.cs