c# INTRODUCTION - Dot Net

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 language 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 C99 can easily understand the programming in C#.
File Extension 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 generate an empty "Program" class, with "Main()" method.
  • To run the application simply press F5 key on the keyboard. Then the application will be executed and output will be displayed.
1.Importing section:
  •     This section contain importing statement that are used to import the .NET Framework Class Library(FCL).
  • This is most similar to the include statements in "C" laguage.
Syntax:

     using namespace;

Note: If the required namespace is a member of another namespace, we have specify the parent and child namespaces separated with  "." (dot).

Example

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.
      Syntax:
          namespace namespaceName
         {
          .
          .
          }

Generally the namespace name will be same as "Project" name.

2. 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.
       Syntax:
         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 contain the main logic of the application.
     Syntax:
      class Program
     {
          static void Main(string[] args)
        {
            Console.WriteLine("Hello, World");
            Console.ReadLine();
        }
     }

Compiling and Running the Application
  •  Compile : Click on "Build menu - "Build Solution". (or) press Ctrl+Shift+B.
  • Run : Click on "Debug" menu - "Start Debugging".(or) Press F5 or Ctrl+F5. 

Comments