C# Tutorial
C# (pronounced C-sharp) is a modern, object-oriented programming language developed by Microsoft. It is widely used to build Windows applications, web applications, mobile apps, games (using Unity), and enterprise software systems.
C# runs on the .NET runtime, which allows applications to execute on multiple platforms including Windows, macOS, and Linux with .NET Core and later versions of .NET. Its syntax is similar to other C-based languages like C++ and Java.
Hello World Program
using System;
class HelloWorldProgram {
static void Main(string[] args){
// "printing Hello World"
Console.WriteLine("Hello, World!");
}
}
Output
Hello, World!
Introduction to C#
This section introduces C#, explains its purpose, and sets up the environment to start coding.
- Introduction
- Installing and Setup Visual Studio Code
- Setting Up Environment Variables
- Executing Program on CMD
Basics
Learn the building blocks of C# such as variables, data types, and operators.
- Identifiers
- Variables
- Data Types
- Constants and Literals
- Scope of Variables
- Params
- Type Casting
- Comments
- Operators
Control Structures
This section covers flow control statements used in decision-making and looping.
- Decision Making: If-Else, Switch-Case
- Loops: For, While, Do-While
- Foreach Loop
- Jump Statements: Break, Continue
Arrays & Strings
Understand arrays for storing data collections and string manipulation techniques.
- Introduction to Arrays
- Jagged Arrays
- Sorting an Array
- Introduction to String
- Verbatim String Literal
- String vs StringBuilder
OOP Concepts
C# is object-oriented. This section covers key OOP principles and implementation.
- Class and Objects
- Methods
- Constructors
- Destructors
- Properties
- Access Modifiers
- Abstraction
- Encapsulation
- Inheritance
- Method Overloading
- Method Overriding
- Abstract Classes
- Interface
Delegates, Events and Lambdas
This section covers event-driven programming and functional constructs in C#.
Tuple, ValueTuple and Indexers
This section covers advanced data handling using tuples and indexers.
Generics
Generics are used to improve code reusability and type safety. This section covers them.
Exception Handling
By Exception handling, handle runtime errors gracefully in C#. This section covers it.
- Exceptions
- System Level Exception vs Application Level Exception
- Exception Handling (Try-catch-finally)
- Multiple Catch Clause
- Nesting Try - Catch Blocks
Multithreading
Learn concurrent programming in C# in this section.
- Introduction
- Types of Threads
- Creating Threads
- Main Thread
- Lifecycle and States of Thread
- Thread Class
- Thread Priority
- Thread Synchronization
- Thread Safety & Race Conditions
- Joining Threads
- Terminating a Thread
Collections Framework
C# provides rich collections for data handling. They are known as Collection Framework. This section covers them.
- Array Class
- List
- ArrayList
- SortedList
- HashSet
- SortedSet
- Dictionary
- SortedDictionary
- Hashtable
- Stack
- Queue
- LinkedList
- BitArray Class
LINQ (Language Integrated Query)
LINQ helps in writing query data in a clean, SQL-like way inside C#. This section covers LINQ.
.NET Framework
In this section, understand the runtime environment for C#.
- What is .NET Framework
- .NET Framework Architecture
- Managed and Unmanaged Code
- CIL or MSIL
- Common Language Runtime(CLR)
Advanced C# Features
Explore modern and advanced concepts in this section.
- Attributes
- Reflection
- Nullable Types
- Partial Classes
- Static Classes
- Anonymous Types
- Extension Methods
- Index and Range
- Pattern Matching