Composite Pattern - TechNet Articles - United States (English) - TechNet Wiki

Composite pattern treats components as a composition of one or more elements so that components can be separated between one another. In other words, Composite patterns are those for whom individual elements can easily be separated.



/// <summary>
    /// Tst-header">

Composite Pattern

Composite pattern treats components as a composition of one or more elements so that components can be separated between one another. In other words, Composite patterns are those for whom individual elements can easily be separated.

     /// between one another
    /// </summary>
    public interface IComposite
    {
        void CompositeMethod();
    }
 
    public class LeafComposite :IComposite
    {
 
        #region IComposite Members
 
        public void CompositeMethod()
        {
            //To Do something
        }
 
        #endregion
    }
 
    /// <summary>
    /// Elements from IComposite can be separated from others
    /// </summary>
    public class NormalComposite : IComposite
    {
 
        #region IComposite Members
 
        public void CompositeMethod()
        {
            //To Do Something
        }
 
        #endregion
&nbold;">public void Compositebsp;
        public void DoSomethingMore()
        {
            //Do Something more .
        }
    }


Here in the code you can see that in NormalComposite, IComposite elements can easily be separated.