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
- TextBox.cs
- ProfileEventArgs.cs
- UnknownExceptionActionHelper.cs
- StringAnimationUsingKeyFrames.cs
- XPathNodeIterator.cs
- Win32.cs
- MLangCodePageEncoding.cs
- MetadataItemEmitter.cs
- DialogResultConverter.cs
- ServiceEndpoint.cs
- ReflectionTypeLoadException.cs
- WeakReferenceList.cs
- SmiMetaDataProperty.cs
- ColorInterpolationModeValidation.cs
- ImageListUtils.cs
- ContextMenuStripGroup.cs
- PreviewPrintController.cs
- AutomationElement.cs
- ChannelBase.cs
- CounterSampleCalculator.cs
- VectorAnimation.cs
- Registry.cs
- FileChangesMonitor.cs
- NullableDoubleMinMaxAggregationOperator.cs
- BatchStream.cs
- IteratorFilter.cs
- MemberNameValidator.cs
- RowSpanVector.cs
- HttpListener.cs
- LinkedList.cs
- GridViewDeleteEventArgs.cs
- WorkflowInlining.cs
- XmlSchemaProviderAttribute.cs
- PropertyDescriptorCollection.cs
- XPathConvert.cs
- XamlRtfConverter.cs
- TypedDataSourceCodeGenerator.cs
- FixedDocumentPaginator.cs
- FormsAuthentication.cs
- DecoderExceptionFallback.cs
- FontEmbeddingManager.cs
- MeshGeometry3D.cs
- PropertyBuilder.cs
- CloudCollection.cs
- MoveSizeWinEventHandler.cs
- configsystem.cs
- Array.cs
- DataSourceProvider.cs
- StorageEntitySetMapping.cs
- ReliabilityContractAttribute.cs
- DataPagerFieldCommandEventArgs.cs
- ResourceSet.cs
- DbConnectionOptions.cs
- AliasGenerator.cs
- XmlAttributeCache.cs
- DashStyle.cs
- WindowsListViewGroupSubsetLink.cs
- DataFormats.cs
- NativeRightsManagementAPIsStructures.cs
- TypeExtensionConverter.cs
- HttpException.cs
- ProfessionalColorTable.cs
- ReceiveDesigner.xaml.cs
- StaticFileHandler.cs
- ElementHost.cs
- WebPartZoneBase.cs
- ThrowHelper.cs
- ConditionalAttribute.cs
- ObjectSecurityT.cs
- LinqDataSourceView.cs
- FileDataSource.cs
- recordstatefactory.cs
- ContentPresenter.cs
- ForwardPositionQuery.cs
- ErrorTableItemStyle.cs
- FormViewUpdateEventArgs.cs
- SiteMapSection.cs
- DocComment.cs
- SqlDataRecord.cs
- ResourceWriter.cs
- TakeOrSkipQueryOperator.cs
- ResourceDisplayNameAttribute.cs
- PageHandlerFactory.cs
- PageVisual.cs
- InvalidTimeZoneException.cs
- XmlDigitalSignatureProcessor.cs
- MultipleViewProviderWrapper.cs
- XPathNavigator.cs
- RefType.cs
- MailAddressCollection.cs
- TraceContextRecord.cs
- BitmapEffectDrawing.cs
- DelegatedStream.cs
- SignerInfo.cs
- LongAverageAggregationOperator.cs
- OutputCacheSettings.cs
- URLString.cs
- LinqDataSource.cs
- OutgoingWebResponseContext.cs
- SessionChannels.cs