473,387 Members | 1,542 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Breaking up Big FormX.CS files

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;
-----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




.

Nov 15 '05 #1
2 1418
Or wait for Whidbey:
http://msdn.microsoft.com/vstudio/pr...p.aspx#whidbey
-mike
"Sacalul" <ka******@asconsulting.ro> wrote in message
news:04****************************@phx.gbl...
A simple way to split your file:

-----Original Message-----
I'd like
to break the code up into distinct files (broken up by

client), but I'm not
having success doing that.

Nov 15 '05 #2
That'll do it!! Thanks so much!

Harry
Nov 15 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

30
by: Jive | last post by:
Can someone explain to me why Python 2.4 on MS Windows has these backward compatibility problems? What am I missing? Why won't extensions compiled to run with 2.3 also work with 2.4? Why does it...
0
by: MarionEll | last post by:
--------------------------------------------------------- ************* Call for Participation ************** ************ Late Breaking News ************* *********** Extreme...
2
by: Jacob | last post by:
A problem I've been rather stuck on and, try as I might, have not been able to find the answer to. I've written a nice little class that I want to include in another project. The class works...
22
by: stevenkobes | last post by:
If a word has a hyphen in it, IE will permit a line break at the hyphen, but Firefox/Mozilla won't. Apparently the Firefox behavior is standards-compliant, but it is not what I want. Is there a...
7
by: Mark | last post by:
Hi... A colleague just referred this question to me. He's getting an xml file from another party, which he's trying to process into another dom using an XmlTextReader and...
6
by: Ritesh Raj Sarraf | last post by:
Hi, Following is the code: def walk_tree_copy(sRepository, sFile, sSourceDir, bFound = None): try: if sRepository is not None: for name in os.listdir(sRepository): path =...
4
by: Bit Byte | last post by:
I'm having problem compiling one of my projects with VS2005. The problems arise with VS2005 (apparent?) inability to compile log4cpp. Has anyone succesfully compiled log4cpp using VS2005? Here...
13
by: Andrew | last post by:
Hi I was wondering if there is anyway with XML RPC to send a string of text from the server to the client with out calling return thus breaking my loop for example def somefunc(): for...
1
by: mailbox73 | last post by:
Hi, c# 2008 express edition. Can anyone please help me figure out why I cannot get any value from one form to another when the controls are databound. (the formY.txtbox lands up empty) in...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.