Tag Archives: interfaces

Find class ancestors in C#

The example Find classes that implement an interface or that are descendants of a given class in C# shows how to find a list of classes that are descendants of a class or interface. This example uses similar code to … Continue reading

Posted in classes, inheritance, interfaces, reflection | Tagged , , , , , , , , , , , , , , , | Leave a comment

Find classes that implement an interface or that are descendants of a given class in C#

This example lets you find classes that are part of an inheritance or implementation hierarchy. When you enter a class or interface name and click Find, the example uses the following code to search the currently loaded assemblies for classes … Continue reading

Posted in classes, inheritance, interfaces, reflection | Tagged , , , , , , , , , , , , , , | 1 Comment

Provide multiple inheritance in C#

Sometimes you might want a class to inherit from more than one parent class. For example, you might define a Vehicle class that has vehicle properties such as MaxSpeed, and a Domicile class with house-like properties such as SquareFeet. You … Continue reading

Posted in inheritance, interfaces, OOP | Tagged , , , , , , , , , | Leave a comment

Define and implement an interface in C#

(This example doesn’t do anything. It just shows how to define an interface.) An interface defines properties, methods, and events for a class but doesn’t provide an implementation for them. A class that implements the interface must provide code for … Continue reading

Posted in interfaces, OOP | Tagged , , , , , , , , , | Leave a comment

Make a list without duplicates in C#

This example builds a list of Person objects without duplicates. The following code shows the Person class. public class Person : IEquatable<Person> { public string FirstName, LastName; public Person(string first_name, string last_name) { FirstName = first_name; LastName = last_name; } … Continue reading

Posted in generic, lists | Tagged , , , , , , , , , , , | Leave a comment

Implement an interface in C#

Before you can implement an interface, you need to know what an interface is. An interface defines properties, methods, and events that an object must provide to satisfy the interface without providing any implementation of those features. If a class … Continue reading

Posted in interfaces, OOP | Tagged , , , , , , , , , , | 1 Comment

Select ComboBox or ListBox values that contain target text in C#

The List timezones in C# example fills a ComboBox with a list of timezones. I would like to select an initial value based on the text in the items, but I don’t want to have to select the exact text, … Continue reading

Posted in controls, interfaces | Tagged , , , , , , , , , , , , , , | Leave a comment

Sort objects in C#

This example shows how you can easily sort objects in C#. Sorting algorithms are absolutely fascinating and I recommend that everyone study them at some point. Different algorithms demonstrate interesting and useful techniques such as recursion, divide-and-conquer, linked data structures, … Continue reading

Posted in algorithms | Tagged , , , , , , , , , , , , , , | Leave a comment