简体   繁体   中英

When and why we should to use class System.ComponentModel.Container?

Is anybody could explain when and why we should use System.ComponentModel.Container , please? Recently I have met using of this class here , but really cannot understand what a benefit can get us this class there.

In general, System.ComponentModel namespace exists for supporting component development - components can be visual (controls) and non-visuals. IMO, one should develop Components (in this context IComponent implementations) when design time support is needed. For example, you can drag Components on to the design surface in Visual Studio and access their properties. In this context, IContainer & Container represent a holder that will contain one or more components. I seriously doubt if you need to use System.ComponentModel.Container directly - this class would be used by .NET framework and Visual Studio (or other designer tools) internally. As far as, the code that you have sighted, it appears to be quite outdated and for that matter, it is not even instantiating Component class (just a reference is created).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM