C# Intro
Introduction to C# (C-Sharp) programming language.
What is C#?
C# (pronounced "C-Sharp") is an object-oriented programming language developed 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 (Unity)
- VR
- Database applications
- And much, much more!
Why Use C#?
- It is one of the most popular programming languages 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
Examples
Hello World
A simple C# program that prints 'Hello World!' to the console.
using System;
namespace HelloWorld
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Hello World!");
}
}
}Simple Calculation
Adds two numbers and prints the result.
using System;
namespace Calculator
{
class Program
{
static void Main(string[] args)
{
int x = 5;
int y = 6;
Console.WriteLine(x + y);
}
}
}Variables Example
Declaring and printing a string variable.
using System;
namespace Variables
{
class Program
{
static void Main(string[] args)
{
string name = "John";
Console.WriteLine(name);
}
}
}