Chapter 2_ADT-II
Chapter 2_ADT-II
C# is pronounced "C-Sharp".
C# has roots from the C family, and the language is close to other popular
languages like C++ and Java.
The first version was released in year 2002. The latest version, C# 12, was
released in November 2023.
C# is used for:
Mobile applications
Desktop applications
Web applications
Web services
Web sites
Games
VR
Database applications
And much, much more!
Program:
using System;
namespace HelloWorld
class Program
Console.WriteLine("Hello World!");
Description:
Line 2: A blank line. C# ignores white space. However, multiple lines makes the
code more readable.
Line 3: namespace is used to organize your code, and it is a container for classes
and other namespaces.
Line 4: The curly braces {} marks the beginning and the end of a block of code.
Line 5: class is a container for data and methods, which brings functionality to
your program. Every line of code that runs in C# must be inside a class. In our
example, we named the class Program.
Line 7: Another thing that always appear in a C# program, is the Main method.
Any code inside its curly brackets {} will be executed. You don't have to
understand the keywords before and after Main. You will get to know them bit
by bit while reading this tutorial.
C# Variables
Variables are containers for storing data values.
In C#, there are different types of variables (defined with different keywords),
for example: