Figure 2-2. (Apache web server) Your first Windows Forms application Compiling
Figure 2-2. Your first Windows Forms application Compiling Multiple Source Files with csc.exe The current incarnation of the TestApp.exe application was created using a single *.cs source code file. While it is perfectly permissible to have all of your .NET types defined in a single *.cs file, most projects are composed of multiple *.cs files to keep your code base a bit more flexible. Assume you have authored an additional class contained in a new file named HelloMsg.cs: // The HelloMessage class using System; using System.Windows.Forms; class HelloMessage { public void Speak() { MessageBox.Show(”Hello…”); } } Now, update your initial TestApp class to make use of this new type, and comment out the previous Windows Forms logic: using System; // Don’t need this anymore. // using System.Windows.Forms; class TestApp { public static void Main() { Console.WriteLine(”Testing! 1, 2, 3″); // Don’t need this anymore either. // MessageBox.Show(”Hello…”); // Exercise the HelloMessage class! HelloMessage h = new HelloMessage(); h.Speak(); } } You can compile your C# files by listing each input file explicitly: csc /r:System.Windows.Forms.dll testapp.cs hellomsg.cs As an alternative, the C# compiler allows you to make use of the wildcard character (*) to inform csc.exe to include all *.cs files contained in the project directory as part of the current build: csc /r:System.Windows.Forms.dll *.cs CHAPTER 2 38 BUILDING C# APPLICATIONS
Note: In case you are looking for affordable and reliable webhost to host and run your j2ee application check Vision J2ee Web Hosting services.