System.Collections.IComparer Interface
Information   Base Types   Related Resources

Exposes a method that compares two objects.

  • Namespace: System.Collections
  • First seen in: .NET v1.0.3705
  • Last seen in: .NET v1.1.4322
  • Last changed in: .NET v1.0.3705
  • Assembly: mscorlib.dll

  • View this type on MSDN
  • View this type on WinFX 247
    Articles (26)Discussions (153)MembersRotorChanges
    Articles

    Page: 12
    .NET - More on Generics in the CLR
    MSDN
    More on Generics in the CLR
    A Dictionary Collection Sorting By Value
    The Code Project
    An article on creating a custom collection like the SortedList that sort entries by value instead of by key
    A Grouping and Subtotaling Repeater for ASP.NET
    DotNetJunkies
    A recent project had a user interface requirement where data could be displayed two ways: either in chronological order or grouped by family member. I solved the "not so easy" grouping by family member requirement by modifying the Repeater control, as you'll see in this article.
    A Grouping repeater controls for ASP.Net
    The Code Project
    This custom repeater control can be used to add group headers to your output.
    A Simple Usage of Reflection
    DotNetJunkies
    Xico takes a quick look at what Reflection is all about and explains what it can do for you.
    An Interface-based Approach to .NET
    http://www.csharpnewsletter.com/
    In this article, Brian Boyce explains what interfaces are and how they're used, and provides some methods for working with them. He also demonstrates how interfaces differ from abstract classes.
    Collection and Object Ordering
    C# Corner
    Net SDK provides a number of collection classes in the System.Collections namespace. We use these collection classes to store objects inside them and perform some operation on them later on as per application logic. Many times we need to re-order objects stored inside these collection. Most collection classes provide a method called Sort() to re-order their elements. The objective of this article is to use Sort() method to order elements stored in a collection class in a generic fashion.
    Creating a Regular Expression Checker
    devCity.NET
    This article will attempt to explain the steps involved with creating a WinForm application that will validate regular expressions using the System.Text.RegularExpression namespace. The application will accept two inputs. The first input will be a string to search. The second input will be the regular expression that serves as our search criteria.
    Creating Custom Collections
    FLWS.com.au
    Even though the FCL offers many different collection types such as the SortedList, ArrayList, Hashtable etc., sometimes it makes sense to create your own. Creating your own, custom collection can help to make your code more self describing.
    Directory Picker Dialog
    C# Corner
    Although the open file dialog is a good tool for picking files, sometimes its the desire of the programmer to have a dialog that chooses a directory. This simple directory picker should get you started on this useful windows function. I wrote a previous article on this topic for Beta 1, but wanted to redo it for Beta 2. This Directory Picker in this article is also a bit different because it uses the "Large Icon" view of the ListView to traverse through directories.
    Exposing Proprietary Data the .NET Way
    MSDN
    The .NET Framework comes with the OLE DB managed provider, which is meant to be a bridge that gives you immediate access to all the existing OLE DB providers. This component saves your current investments, as applications can continue successfully calling into existing OLE DB providers. The point, though, is another. In .NET, exposing proprietary data requires a more thoughtful choice, mostly because you have multiple and equally powerful options from which to choose.
    Generic Sorting
    http://aspalliance.com/
    Write that sort code once and for all. Harness the power of reflection to easily genericise your sort logic to work on any properties with multiple levels and differing orders.
    How to sort a ListView control by a column in Visual C++ .NET
    Microsoft Support
    (816183) - This step-by-step article describes how to sort a ListView control by a column in your Microsoft Visual C++ .NET application. When you are working with the ListView control, you may want to sort its contents based on specific column data. An example...
    How to use the IComparable interface and the IComparer interface in Visual C++ .NET 2003
    Microsoft Support
    (816192) - Discusses how to use the IComparer interface and the IComparable interface. These interfaces are frequently used together, and although the interfaces are similar and have similar names, they serve different purposes.
    How to use the IComparable interface and the IComparer interface in Visual C++ .NET 2003
    http://www.kbalertz.com/
    (816192) - Discusses how to use the IComparer interface and the IComparable interface. These interfaces are frequently used together, and although the interfaces are similar and have similar names, they serve different purposes.
    Longhorn Foghorn: Still Crazy After All These Bindings
    MSDN
    Chris Sells explores how views maintain the current item and how they support filtering and sorting. He then looks at transforms for binding to data of one type and mapping to data of another type or in a different range of values.
    Modularizing Object Collections With The Collections API
    C#Today
    The Collections API in the .NET Framework merits close attention by all .NET developers because of the flexibility it offers for writing applications in .NET. We can use it to manage groups or collections of similar objects, standardizing the way in which groups of objects are handled by our programs. In this article, Thiru Thangarathinam takes us through a tour of all the important collection classes by showing us examples, and then goes on to show us how these collection classes can be very useful in the day-to-day work of a developer.
    Sort titles using a TitleComparer
    The Code Project
    An implementation of the IComparer interface that allows strings to be sorted as Titles
    Sort titles using a TitleComparer
    The Code Project
    An implementation of the IComparer interface that allows strings to be sorted as Titles.
    Sorting a ListView with VB.NET
    STANDARDIO.ORG
    Every so often, while happily coding along in .NET, I’ll run into an object with a few methods that just don’t make sense. The .NET ListView object was just one of those. In VB6 it was a piece of cake to sort by columns in a ListView. All you did was pass it the index of the column you wanted to sort by. Now, in .NET, things have gotten a little bit more complicated. The gist of the new method is this: you must create your own custom class that implements the IComparable interface and overrides the Compare Function with your own code. Then take that class and set the ListViewItemSorter property of the ListView equal to it. Take a look at the custom class below and then see how it is used in the column click event of the ListView object.
    Sorting Algorithms In C#
    The Code Project
    A collection of sorting algorithms implementing customizable comparitor and swapper functions.
    Sorting MultiColumn ListView Windows Forms Control
    C# Corner
    If you want to sort on the first column of a ListView, simply click the Sorting in the properties Window and choose Ascending or Descending as a value. If you want to do sorting in all the columns of a ListView, you need to write custom sorting using the ListViewItemSorter property. This property allows you to assign the property to an instance of a custom class that implements the IComparer interface.
    Sorting objects using IComparer and IComparable Interfaces
    C# Corner
    The System.Collections namespace contains interfaces and classes that define various collections of objects, such as lists, queues, bit arrays, hashtables and dictionaries. You can use a collection to store objects, some collection implementations would sort your objects by default when they are added to the collection and some would just add them in sequence. Once the objects are added to a collection if a custom ordered list (custom sorting) of stored objects is required IComparer interface form System.Collections namespace and IComparable interface from System namespace comes in handy.
    Tips and Tricks
    MSDN
    During our last episode, we used unsafe code to do some image processing. In this column, we were supposed to spend some more time exploring unsafe code, but I've decided to change the program a bit. I have two motivations for this change. The first is that I haven't gotten around to writing the code yet. The second is that I'd like to answer a few common questions so that I don't spend so much time answering them elsewhere. Next month, we'll continue our exploration of unsafe code—probably.
    Use Inheritance to Create a Custom TreeView
    devCity.NET
    This article demonstrates how to build a treeview where the nodes are based on different objects. A simple example is a folder and file hierarchy where each object needs different properties. A more complex example is an object model with a class at one level and with methods, properties, events, etc., at a level below that. In this example, Category is at the top level and AccountType and PartType are the second-tier nodes. Each class will contain a property that is not part of the other classes. In the real world each of these classes might be very different from each other.
    Ad
    MBR BootFX
    Best-of-breed application framework for .NET projects, developed by Matthew Baxter-Reynolds and MBR IT
     
     Copyright © Matthew Baxter-Reynolds 2001-2008. '.NET 247 Software Development Services' is a trading style of MBR IT Solutions Ltd.
    Contact Us - Terms of Use - Privacy Policy - www.dotnet247.com