Code:
/ Dotnetfx_Vista_SP2 / Dotnetfx_Vista_SP2 / 8.0.50727.4016 / DEVDIV / depot / DevDiv / releases / whidbey / NetFxQFE / 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
- _NetworkingPerfCounters.cs
- ClientUtils.cs
- TransformerInfo.cs
- CompressStream.cs
- ConfigurationLoader.cs
- LayoutUtils.cs
- xdrvalidator.cs
- SourceLineInfo.cs
- XmlUTF8TextReader.cs
- RichTextBox.cs
- EventMappingSettings.cs
- PolyBezierSegment.cs
- SqlReferenceCollection.cs
- VirtualPath.cs
- TextRangeEdit.cs
- ImageKeyConverter.cs
- SchemaCreator.cs
- _SecureChannel.cs
- AutoResizedEvent.cs
- DocumentOrderQuery.cs
- ValidationSummary.cs
- CSharpCodeProvider.cs
- LeafCellTreeNode.cs
- ServiceHostingEnvironmentSection.cs
- WorkflowApplicationUnloadedException.cs
- TabControlCancelEvent.cs
- EntryPointNotFoundException.cs
- CommandTreeTypeHelper.cs
- QualificationDataAttribute.cs
- TraceSource.cs
- ObjectConverter.cs
- SuppressMessageAttribute.cs
- DBSchemaTable.cs
- RectangleF.cs
- Delegate.cs
- NamedPermissionSet.cs
- Style.cs
- ItemCheckedEvent.cs
- CompositeCollectionView.cs
- XmlDataDocument.cs
- ProgressBar.cs
- IntPtr.cs
- SymmetricKeyWrap.cs
- ComponentEvent.cs
- SizeChangedInfo.cs
- baseshape.cs
- TemplateComponentConnector.cs
- FragmentQuery.cs
- WpfPayload.cs
- Vector3DAnimation.cs
- Behavior.cs
- SingleAnimationBase.cs
- Certificate.cs
- OpenTypeMethods.cs
- HealthMonitoringSectionHelper.cs
- PrefixHandle.cs
- ParagraphResult.cs
- XPathAncestorIterator.cs
- SafeFileMappingHandle.cs
- Form.cs
- BlockCollection.cs
- TreeViewEvent.cs
- RowCache.cs
- GrammarBuilder.cs
- ManifestBasedResourceGroveler.cs
- EntityParameterCollection.cs
- CategoryAttribute.cs
- RequiredFieldValidator.cs
- XPathBuilder.cs
- ActivityCodeGenerator.cs
- HttpRuntime.cs
- DragEventArgs.cs
- WaitHandle.cs
- LabelInfo.cs
- KnownBoxes.cs
- UndoManager.cs
- ImageMapEventArgs.cs
- TableItemPattern.cs
- SizeAnimationClockResource.cs
- MSAANativeProvider.cs
- Decimal.cs
- InvalidTimeZoneException.cs
- XmlILOptimizerVisitor.cs
- Cursor.cs
- SendMailErrorEventArgs.cs
- WebPartDisplayModeCancelEventArgs.cs
- PingReply.cs
- WaitHandleCannotBeOpenedException.cs
- ExtenderProviderService.cs
- ObjectStateFormatter.cs
- DataSourceGroupCollection.cs
- HttpChannelListener.cs
- ArrangedElement.cs
- EntityContainerEmitter.cs
- FamilyCollection.cs
- PersonalizablePropertyEntry.cs
- SmiEventSink.cs
- ThicknessKeyFrameCollection.cs
- ScriptBehaviorDescriptor.cs
- ParserOptions.cs