C# allows us to write programs like Console Bases Applications as well as Windows Based Applications. The following links give you a basic idea of Console Based Application and Windows Based Application.
1. Console based application
The following program is a simple console based CSharp application. The program starts from the main () method. Create a new Console Application project and copy and paste the following C# source code.
using System; using System.Collections.Generic; using System.Text; namespace ConsoleApplication1 { class Program { static void Main(string[] args) { Console.WriteLine(“My First Program”); Console.ReadKey(); } } }
2. Windows based application
The following program is a simple window based CSharp application. This program has a form (named Form1) . Program starts with the constructor of Form1().
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace WindowsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
MessageBox.Show("This is my first program");
}
}
}