Define C#.Net

C#.Net is a modern, general-purpose, object-oriented programming language developed by Microsoft that runs on .Net Framework. C# combines the good features of C++ and Java. C# is a case sensitive programming languages. C# can be used to create various types of applications, such as console applications, windows applications, web applications or other types of applications like web services, database applications etc.

C# Features

C# is object oriented programming language. It provides a lot of features that are given below:

  1. Simple - C# is a simple language, it provides structured, rich set of library functions, data types etc.
  2. Modern programming language - C# programming is based upon the current trend and it is very powerful and simple for building scalable, interoperable and robust applications.
  3. Object oriented - C# is object oriented programming language. OOPs makes development and maintenance easier where as in Procedure-oriented programming language it is not easy to manage if code grows as project size grow.
  4. Type safe - C# type safe code can only access the memory location that it has permission to execute. Therefore it improves a security of the program.
  5. Interoperability - Interoperability process enables the C# programs to do almost anything that a native C++ application can do.
  6. Scalable and Updateable - C# is automatic scalable and updateable programming language. For updating our application we delete the old files and update them with new ones.
  7. Component oriented - C# is component oriented programming language, used to develop more robust and highly scalable applications.
  8. Structured programming language - C# is a structured programming language in the sense that we can break the program into parts using functions. So, it is easy to understand and modify.
  9. Rich Library - C# provides a lot of inbuilt functions that makes the development fast.
  10. Fast speed - The compilation and execution time of C# language is fast.

Creating your first C#.NET application

Example 1: Print 'Hello World'

using System;

namespace HelloWorld
    class Program
        static void Main(string[] args)
            /* my first program in C# */
            string message = "Hello World!";
C# hello world
Code Explanation:
  • using System;: It is the .Net framework namespace, contains classes, methods. Every C# program must use 1 or more namespaces.
  • namespace HelloWorld: Declaring custom namespace 'HelloWorld' using namespace keyword.
  • class Program: Declaring class 'Program' using class keyword.
  • static void Main(string[] args): Main() is a method, which is the entry point of every C# program, void means method is not returning any value, it must use static and string array argument. static means without creating object of class we can access its method.
  • /* my first program in C# */: This is a multi-line comment.
  • string message = "Hello World!";: string is a datatype, message is a variable name hold the value "Hello World"
  • Console.WriteLine(message);: WriteLine is a method use to display message to the console (output) screen. This method is already mentioned in Console class in System namespace.
  • Console.ReadLine();: ReadLine method is use to take input, here we are using this to hold the output screen until user press any key.
Compile and Run C# Program

In order to see the output of the C# program, we have to compile it and run it by pressing Ctrl+F5 or clicking Run button from the toolbar.