using System;
using System.Collections.Generic;
using System.Text;
namespace ConsoleApplication2
{
class Program
{
}
public partial class sub
{
int a,b,c;
public void method()
{
a=10;
b=20;
c=a+b;
}
}
public partial class sub
{
public void display()
{
method();
Console.WriteLine("C Value is :"+ c);
Console.ReadLine();
}
static void Main(string[] args)
{
sub sd=new sub();
sd.display();
sd.meth();
}
}
}
Class1.cs:
using System;
using System.Collections.Generic;
using System.Text;
namespace ConsoleApplication2
{
class Class1
{
}
public partial class sub
{
public void meth()
{
method();
Console.WriteLine("C value is:" + c);
Console.ReadLine();
}
}
}
- Partial Class name should be same in both Program.cs and Class1.cs file.
- We can use the method from one class file to another class file.
- Easily Debugging.
- Sharing the class is easy.
- Multiple developers can work at a time.
- But the compiler merges these 2 classes and it will compile.
- The assembly should unique for these 2 class files.
No comments:
Post a Comment