Breaking up Big FormX.CS files

  • Thread starter Thread starter Sacalul
  • Start date Start date
S

Sacalul

A simple way to split your file:
- create a class BasicClient.cs:
using System;
namespace Test
{
public abstract class BasicClass{
public BasicClass(){}
public abstract string DoClient();
//add here other abstract methods
}
}
- create a class Client1.cs:
using System;
namespace Test
{
public class Client1:BasicClient{
public Client1(){}
public override string DoClient()
{return "DoJob Client 1"; //your code}
}
}
- create a class Client2.cs:
using System;
namespace Test
{
public class Client2:BasicClient{
public Client2(){}
public override string DoClient()
{return "DoJob Client 2"; //your code}
}
}
- in Form1.cs do something like this:
BasicClient objBC = null;
if (bIsClient1)
objBC = new Client1(); string strJB=objBC.DoClient();
else
if (bIsClient2)
objBC = new Client2(); string strJB=objBC.DoClient();
objBC = null;
 
Back
Top