29 July 2013

partial classes in C#

partial classes: ----  a single class splitted into multiple files is called as partial classes.

1. partial class allows you to define a class on multiple files.
2. the adv in this approach was splitting the huge volumes  ar related code into multiple  or saparate   
    files which makes eas to organize.
3.as the code is now defined on multiple files multople programers can word in same class at the same   
     time.

using system;
using system.collections.generic;
using system.linq;
using system.text;

namespace oopsproject
{
   partial class parts
    {
       public void method3()
       {
           Console.WriteLine("method3");
       }
       public void method4()
       {
           Console.WriteLine("method4");
       }
    }
}

This is a class with the name partialtest. this class is used for test the partial classes parts.

using system;
using system.collections.generic;
using system.linq;
using system.text;

namespace oopsproject
{
    class partialtest
    {
        static void Main()
        {
            parts p = new parts();
            p.method1();
            p.method2();
            p.method3();
            p.method4();
            console.readkey();
        }
    }

}

No comments:

Post a Comment