Introduction to C#
Course Code: CSE0613201
Prepared By: Sumaiya Tanjil Khan (STK)
What is C#?
● C# is pronounced as "C-Sharp".
● Anders Hejlsberg is known as the founder of C# language.
● 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
● Scalable and Updateable
● Structured programming language
● Rich library
● 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
➔ Program.cs
using System;
class Program
public static void Main(string[] args)
Console.WriteLine("Hello World!");
}
C# Output
To output values or print text in C#, you can use the WriteLine() method.
Examples:
Console.WriteLine("Hello Class!");
Console.WriteLine("You are Learning C#");
Console.WriteLine("Programming is fun!");
Output:
Hello Class!
You are Learning C#
Programming is fun!
● There is also a Write() method, which is similar to WriteLine().
● The only difference is that it does not insert a new line at the end of
the output.
Example:
Console.Write("This is another write method!");
Console.Write("Notice the change.");
Output:
This is another write method!Notice the change.
C# Comments
Comments can be used to explain C# code, and to make it more readable. It
can also be used to prevent execution when testing alternative code.
➔ Single-line Comments
Single-line comments start with two forward slashes (//).
Example:
// this below line shows output.
Console.WriteLine("Hello Class!");
➔ C# Multi-line Comments
Multi-line comments start with /* and ends with */.
Example:
/* The code below will print the words Hello World
to the screen, and it is amazing */
Console.WriteLine("Hello World!");
Backslash characters/ Escape sequences
Notation Operation
\n New line
\b Backspace
\t Horizontal tab