C#

How to Sort Arraylist in C# with IComparer

In this program, you’ll learn to sort an ArrayList of custom object by their given property in C#.




In the below program, we’ve defined a Student class with a string and int properties, Name and Age. We’ve also added a constructor that initializes the properties.

And In Program class, I created a class that implements IComparer, and provide that.(icomparer C# Example)

 

Finally ,I created the program class as follows.

Output:

 

 

About the author

admin

Leave a Comment