Container Class

Encapsulates zero or more components.

Namespace:  System.ComponentModel
Assembly:  System (in System.dll)

[HostProtectionAttribute(SecurityAction.LinkDemand, SharedState = true)]
public class Container : IContainer, IDisposable

The Container type exposes the following members.

  NameDescription
Public methodSupported by the XNA FrameworkContainerInitializes a new instance of the Container class.
Top

  NameDescription
Public propertyComponentsGets all the components in the Container.
Top

  NameDescription
Public methodSupported by the XNA FrameworkAdd(IComponent)Adds the specified Component to the Container. The component is unnamed.
Public methodSupported by the XNA FrameworkAdd(IComponent, String)Adds the specified Component to the Container and assigns it a name.
Protected methodSupported by the XNA FrameworkCreateSiteCreates a site ISite for the given IComponent and assigns the given name to the site.
Public methodSupported by the XNA FrameworkDispose()Releases all resources used by the Container.
Protected methodSupported by the XNA FrameworkDispose(Boolean)Releases the unmanaged resources used by the Container, and optionally releases the managed resources.
Public methodSupported by the XNA FrameworkEquals(Object)Determines whether the specified object is equal to the current object. (Inherited from Object.)
Protected methodSupported by the XNA FrameworkFinalizeReleases unmanaged resources and performs other cleanup operations before the Container is reclaimed by garbage collection. (Overrides Object.Finalize().)
Public methodSupported by the XNA FrameworkGetHashCodeServes as the default hash function. (Inherited from Object.)
Protected methodSupported by the XNA FrameworkGetServiceGets the service object of the specified type, if it is available.
Public methodSupported by the XNA FrameworkGetTypeGets the Type of the current instance. (Inherited from Object.)
Protected methodSupported by the XNA FrameworkMemberwiseCloneCreates a shallow copy of the current Object. (Inherited from Object.)
Public methodSupported by the XNA FrameworkRemoveRemoves a component from the Container.
Protected methodRemoveWithoutUnsitingRemoves a component from the Container without setting Site to null.
Public methodSupported by the XNA FrameworkToStringReturns a string that represents the current object. (Inherited from Object.)
Protected methodValidateNameDetermines whether the component name is unique for this container.
Top

The Container class is the default implementation for the IContainer interface.

Containers are objects that encapsulate and track zero or more components. In this context, containment refers to logical containment, not visual containment. You can use components and containers in a variety of scenarios, including scenarios that are both visual and not visual.

The components in a container are tracked in a first-in, first-out list, which also defines the order of the components within the container. Added components are appended to the end of the list.

NoteNote

The HostProtectionAttribute attribute applied to this type or member has the following Resources property value: SharedState. The HostProtectionAttribute does not affect desktop applications (which are typically started by double-clicking an icon, typing a command, or entering a URL in a browser). For more information, see the HostProtectionAttribute class or SQL Server Programming and Host Protection Attributes.

.NET Framework

Supported in: 4.5, 4, 3.5, 3.0, 2.0, 1.1, 1.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.
Was this page helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2014 Microsoft