Category 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 , , , , , , , , , | 1 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

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

Use Visual Studio to implement an interface explicitly or implicitly in C#

Suppose you create a class and in the declaration you indicate that it implements an interface. If you right-click the interface’s name, the dropdown displayed by Visual Studio includes an “Implement Interface” submenu. If you look at the picture on … Continue reading

Posted in interfaces, syntax | Leave a comment