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

Basics_of_CSharp

C# is a modern, object-oriented programming language developed by Microsoft, used for various applications including desktop and web apps. To start coding in C#, one needs to install the .NET SDK and use an editor like Visual Studio. The document covers basic syntax, variables, data types, operators, control flow, and methods in C#.

Uploaded by

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

Basics_of_CSharp

C# is a modern, object-oriented programming language developed by Microsoft, used for various applications including desktop and web apps. To start coding in C#, one needs to install the .NET SDK and use an editor like Visual Studio. The document covers basic syntax, variables, data types, operators, control flow, and methods in C#.

Uploaded by

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

Basics of C#

1. What is C#?

C# (pronounced C-sharp) is a modern, object-oriented programming language developed by

Microsoft. It's commonly used for building desktop apps, web apps, games (with Unity), and more.

2. Setting Up

To start coding in C#:

- Install .NET SDK (for running C# apps)

- Use an editor like Visual Studio or VS Code

3. Basic Syntax

A simple C# program looks like this:

using System;

class Program

static void Main(string[] args)

Console.WriteLine("Hello, World!");

- 'using System;' imports the System namespace

- 'Main' method is the entry point of the program

- 'Console.WriteLine' prints text to the console

4. Variables and Data Types


C# is strongly typed, so you must declare the type of variable:

int age = 25;

string name = "Alice";

bool isStudent = true;

double height = 5.9;

5. Operators

C# supports common operators like:

- Arithmetic: +, -, *, /, %

- Comparison: ==, !=, <, >, <=, >=

- Logical: &&, ||, !

6. Control Flow

If/Else:

if (age >= 18)

Console.WriteLine("Adult");

else

Console.WriteLine("Minor");

Switch:

switch (day)

case "Monday":

Console.WriteLine("Start of week");
break;

default:

Console.WriteLine("Another day");

break;

Loops (for example):

for (int i = 0; i < 5; i++)

Console.WriteLine(i);

7. Methods (Functions)

Functions in C# are written like this:

static int Add(int a, int b)

return a + b;

You can call it using:

int sum = Add(5, 3);

You might also like