Component Class Characteristics
The characteristics of a class acquire additional significance when the class becomes a component.
Component Name
Choose component class names carefully. A class name should be short but descriptive, formed from whole words, with individual words capitalized — for example, BusinessRule. This provides a convenient way to organize your components and to produce shorthand clues to component functions.
Access Modifier
A class defined with private access is not visible to users of your assembly. This is the access level to use for helper classes internal to the assembly.
Setting the Access modifier to public makes a component class available to users of your assembly. To control whether users of your assembly can create instances of the component, specify the appropriate access level for its constructor.
Base Class
Unless you intend to implement the IComponent interface yourself, your base class should be System.ComponentModel.Component or a class that derives from System.ComponentModel.Component. You can find this information in the reference topic for any class in the .NET Framework. In Visual Basic, the Inherits statement specifies the base class. In C#, the base class follows the colon in the class declaration. Examples are shown below:
Imports System.ComponentModel
Public Class MyComponent
Inherits System.ComponentModel.Component
End Class
using System.ComponentModel
public class MyComponent : System.ComponentModel.Component
{}
Namespace Statement
Every component is contained within a namespace. By default, the namespace is the name of your project. Users of your component assembly will add Imports (Visual Basic) orusing (C#) statements for the namespaces containing components they want to access.
Note You can add additional levels of structure by enclosing components within additional Namespace...End Namespace blocks.
Generally speaking, the structure of namespaces in your component assembly should reflect its internal organization. If your assembly contains a large number of components, it makes sense to group related components in separate namespaces.
See Also
Concepts
Initialization and Termination of Components
Component Instancing Changes in Visual Basic