- 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;
-----Original Message-----
I have a WIN32 C# application which is basically a single main form and apreference dialog. I customize the behavior of this application for variousclient configurations, and my Form1.cs file is getting unwieldy. I'd liketo break the code up into distinct files (broken up by client), but I'm nothaving success doing that.
My application has a namespace
namespace WonderBoy
In the Form1.cs file, the following class is defined:
public class Form1 : System.Windows.Forms.Form
within that class I have various client-specific sections like:
private bool DoClient1()
private bool DoClient2()
I'd like to move DoClient1() to a new file (client1.cs) and DoClient2() toclient2.cs. When doing so, I can move the DoClient1() code to client1.cs,but then Form1 barks during compile link with an unresolved reference forDoClient1().
In C++, I could spread a large class over multiple files without problemsusing a common header file showing all of the class members. But I'mscratching my head as to how to do this in C#. Can anyone point me in theright direction?
TIA
Harry
.