tags:

views:

54

answers:

2

I'm new to C# and I am using VS08, I have created a form but where should I be placing my functional code?

Right now I have 2 files:
program.cs

using System;
using System.Collections.Generic;
using System.Linq;
using System.Windows.Forms;

namespace WindowsFormsApplication1
{
    static class Program
    {
        /// <summary>
        /// The main entry point for the application.
        /// </summary>
        [STAThread]
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Application.Run(new Form1());
        }
    }
}

form1.cs - which contains my form.

+1  A: 

Your code should be contained in the classes that make up your domain functionality. Program.cs creates an instance of your form (suggest you rename from form1 to something more descriptive), and your form in turn should instantiate the classes it requires.

If you are using databinding, add one or more binding sources to your form, set their datasources and bind during form load.

Mitch Wheat
A: 

I would recommend you create a new class, when you put all your functional code. Use an instance of this class inside the form1.cs(rename it appropriately).

rAm