Overview

 It’s a programming language, offered by .NET Framework.
 It is recommended for both .NET programming beginners and .NET professionals.
 This is the mostly used languages used by most of the IT companies today.
 It derives some programming features from “C” and “C++” also.
 It is the object oriented programming language.
 The programmer, having knowledge in C and C++ can easily understand the programming in C#.

File Extensions in C#
 Project File Extension: “.csproj” (means C Sharp Project)
 Code File Extension: “.cs” (means C Sharp)

Sample Application Development in C#  Launch Visual Studio 2008.
 Create a new “Console Application” with “Visual C#” language.
 It generates an empty “Program” class, with “Main()” method.
 Type a simple program as follows:
A simple C# program

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApplication3
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Welcome To Hello World");
Console.Read();
}
}
}

 To run the application simply press “F5” key on the keyboard. Then the application will be executed and output will be as follows.


syntax

1. Importing section:
 This section contains importing statements that are used to import (include or link) the .NET Framework Class Library (FCL).
 This is most similar to the “include” statements in “C” language.
 Syn:
using namespace;
 Note: If the required namespace is a member of another namespace, we have specify the parent and child namespaces separated with “.” (dot).
 Ex:
using System;
using System.IO;
using System.Data;
etc.

2. Namespace declaration:
 Here, a user define namespace is to be declared.
 Rule: In .NET applications, all the classes related to the project should be declared in one namespace.
Syn:
namespace namespacename
{

}
 Generally, the namespace name will be same as “Project” name.

3. Class declaration:
 This is to declare the startup class of the project.
 In every .NET application (like Console and Windows Application), there should a startup class. In these applications, the startup class name should be “Program”. You can’t change it.
 A startup class nothing a class, which contains Main() method.
Syn:
class classname
{

}

3. Main() method:
 As you know already in C/C++ languages, the Main() method is the Starting Execution Point of the application.
 When the application is executed, the Main() method will be executed first.
 This method contains the main logic of the application.
Syn:
 main method