Search This Blog

Monday, June 24, 2013

Wrapper class




/// Example for Wrapper class
Structural design patterns 
Proxy, Decorator, and Adapter also use thiw approach.
see more...


public class WrapperExample
{
    private int x = 20;
    private int y = 10;

   
    public WrapperExample()
    {
        //
        // TODO: Add constructor logic here
        //
    }

    public int mul(int x, int y)
    {
        Wrapper.internalClass obj = new internalClass();
        //core functionality of this method is written in the wrapped class.
        int res = obj.mul(x, y);
        return sum;
    }

    ///
    /// this class is wrapped by the WrapperExample class.
    /// we can access only inside this class.
    /// outside the class, we cant access this class.
    ///
    private class internalClass
    {       

        public int mul(int x, int y)
        {
          
            return x * y;
        }
    }
}
 

No comments:

Post a Comment

Blog Archive

About Me

An seasoned developer, architect and with some Team Leading exposure, offering full project life cycle experiences within multi cultural, multi National environments and within differing business streams and all primarily on a .Net platform.