Basic_Functions_of_CSharp
Basic_Functions_of_CSharp
Introduction
C# (pronounced C-Sharp) is a modern, object-oriented programming language developed
by Microsoft. It is widely used for developing desktop applications, web applications, and
games. Below are some basic functions of C# along with examples.
1. Hello World
The 'Hello World' program is the simplest program in C#. It demonstrates the basic
structure of a C# application.
Example:
using System;
class Program
{
static void Main()
{
Console.WriteLine("Hello, World!");
}
}
Example:
3. Conditional Statements
Conditional statements allow you to execute certain blocks of code based on conditions.
Example:
if (number > 0)
{
Console.WriteLine("The number is positive.");
}
else
{
Console.WriteLine("The number is negative.");
}
4. Loops
Loops allow you to execute a block of code multiple times.
5. Functions
Functions (or methods) are blocks of code that perform a specific task.
Example:
Console.WriteLine(AddNumbers(3, 5));