0% found this document useful (0 votes)
2 views

Chapter 2_ADT-II

C# is an object-oriented programming language developed by Microsoft, closely related to C++, Java, and the C family, with its first version released in 2002 and the latest version, C# 12, launched in November 2023. It is widely used for various applications, including mobile, desktop, web, and games, and is popular due to its ease of learning, strong community support, and structured programming approach. The document also provides a brief overview of C# syntax and variable types.

Uploaded by

seema.bandgar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views

Chapter 2_ADT-II

C# is an object-oriented programming language developed by Microsoft, closely related to C++, Java, and the C family, with its first version released in 2002 and the latest version, C# 12, launched in November 2023. It is widely used for various applications, including mobile, desktop, web, and games, and is popular due to its ease of learning, strong community support, and structured programming approach. The document also provides a brief overview of C# syntax and variable types.

Uploaded by

seema.bandgar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

What is C#?

C# is pronounced "C-Sharp".

It is an object-oriented programming language created by Microsoft that runs on


the .NET Framework.

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!

Why Use C#?


 It is one of the most popular programming language in the world
 It is easy to learn and simple to use
 It has a huge community support
 C# is an object oriented language which gives a clear structure to
programs and allows code to be reused, lowering development costs
 As C# is close to C, C++ and Java, it makes it easy for programmers to
switch to C# or vice versa
C# Syntax
In the previous chapter, we created a C# file called Program.cs, and we used
the following code to print "Hello World" to the screen:

Program:

using System;

namespace HelloWorld

class Program

static void Main(string[] args)

Console.WriteLine("Hello World!");

Description:

Line 1: using System means that we can use classes from


the System namespace.

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.

Line 9: Console is a class of the System namespace, which has


a WriteLine() method that is used to output/print text. In our example it will
output "Hello World!".

C# Variables
Variables are containers for storing data values.

In C#, there are different types of variables (defined with different keywords),
for example:

 int - stores integers (whole numbers), without decimals, such as 123 or -


123
 double - stores floating point numbers, with decimals, such as 19.99 or -
19.99
 char - stores single characters, such as 'a' or 'B'. Char values are
surrounded by single quotes
 string - stores text, such as "Hello World". String values are surrounded
by double quotes
 bool - stores values with two states: true or false

You might also like