Hi Guys
NP129 Visual C# 2008 Express / VS.NET 2003
I use Microsoft Visual C# 2008 Express Edition, which is a free download. Also I have Microsoft VS.NET 2003.
When I use Microsoft VS.NET 2003 for Windows Form creation, default code is different from Microsoft Visual C# 2008 Express Edition default code.
I wish to know whether it is advisable to use Express Edition for Windows Form creation. Please help.
Thank you
Microsoft VS.NET 2003 default code
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
namespace fdsafsad
{
///
/// Summary description for Form1.
///
public class Form1 : System.Windows.Forms.Form
{
///
/// Required designer variable.
///
private System.ComponentModel.Container components = null;
public Form1()
{
//
// Required for Windows Form Designer support
//
InitializeComponent();
//
// TODO: Add any constructor code after InitializeComponent call
//
}
///
/// Clean up any resources being used.
///
protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
#region Windows Form Designer generated code
///
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
///
private void InitializeComponent()
{
this.components = new System.ComponentModel.Container();
this.Size = new System.Drawing.Size(300,300);
this.Text = "Form1";
}
#endregion
///
/// The main entry point for the application.
///
[STAThread]
static void Main()
{
Application.Run(new Form1());
}
}
}
Microsoft Visual C# 2008 Express Edition default code
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace fdggdfsg
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
}
}
AlanPosted Aug 20, 2008, 10:08 AM
Here's an explanation of partial classes:
http://msdn.microsoft.com/en-us/library/wa80x488(VS.80).aspx
If you open up Solution Explorer in VC# 2008 Express then, by default, you should see three source code files for a Windows Forms application:
1. Form1.cs which contains the partial class for you to add your own code.
2. Form1.Designer.cs (as a node under Form1.cs) which contains the partial class containing the code generated by the designer including the InitializeComponent method.
3. Program.cs which contains a static class called Program which contains the Main() method.
So, everything's still there but it's been split up into distinct sections. When you get used to this, I'm sure that you'll find it better than VS 2003 as there's a lot less clutter when you're writing your code.
Posted Aug 20, 2008, 10:14 AM
Thank you very much for explanation.
Posted Aug 20, 2008, 9:45 AM
Is there any way to find out partial classes?
I couldn’t see any entry point in the Express Edition default code. Not only that there is no method header for method call InitializeComponent();. In the Consol Applications without these things program won’t execuate. Form to appear on the screen following code must be there. Please explain the reason for missing.
static void Main()
{
Application.Run(new Form1());
}
AlanPosted Aug 20, 2008, 8:50 AM
If I were you, I'd use VC# 2008 Express exclusively now for Windows Forms applications which is an ideal environment for a new C# developer.
This uses the same form model as was introduced in VS 2005 where the code generated by the designer and the code you write yourself are placed in two partial classes. This reduces the chance of your accidentally changing the designer generated code (or the designer over-writing code you've written yourself) and so is a more robust way of doing things.
This wasn't possible in VS 2003 which used C# v1.1 because partial classes were only introduced in C# v2.0.
As you probably know, there have also been a lot more goodies introduced into C# and the .NET framework generally since VS 2003 which are now available in VC# Express 2008.