Creating Components
Important This document may not represent best practices for current development, links to downloads and other resources may no longer be valid. Current recommended version can be found here. ArchiveDisclaimer

Creating Components (Visual C#) 

The term component in the software industry is often used to refer to a reusable object that exposes one or more interfaces to clients in a standardized way. A component may be implemented as a single class, or as a set of classes; the primary requirement is that the basic public interface be well-defined. For example, in the context of native Windows programming, the Component Object Model (COM) requires that all components implement the IUnknown interface in addition to any other specialized interfaces.

In the context of the .NET Framework, a component is a class or set of classes that implements the IComponent interface or one that derives directly or indirectly from a class that implements this interface. The default base class implementation of the IComponent interface is Component.

Some of the most commonly used components in .NET Framework programming are the visual controls that you add to Windows Forms such as the Button Control (Windows Forms), ComboBox Control (Windows Forms), and so on. Non-visual components include the Timer Control, SerialPort, and ServiceController among others.

When you create a component in C#, it can be used by clients written in any other language that conforms to the Common Language Specification.

To create your own components in Visual C#, you can use the Component Designer to assemble non-visual component classes in the same way that you assemble Windows Forms. For more information, see Walkthrough: Creating a Windows Service Application in the Component Designer.

For more information about component programming using Visual Studio, see Components in Visual Studio.

See Also

© 2015 Microsoft