CSharp Detailed Notes
CSharp Detailed Notes
1. Introduction to C#
- C# is an object-oriented programming language developed by
Microsoft.
- It runs on the .NET framework.
- C# is used to develop web apps, desktop apps, games, and more.
2. Basic Syntax
- Every C# program must contain a Main method:
static void Main(string[] args) { ... }
- Statements end with a semicolon `;`
- Curly braces `{}` define blocks of code.
3. Data Types
- int, float, double, char, string, bool
- Example: int x = 10;
5. Operators
- Arithmetic: + - * / %
- Comparison: == != > < >= <=
- Logical: && || !
6. Control Statements
- if, else if, else
- switch-case
- Loops: for, while, do-while, foreach
8. Functions (Methods)
- Methods allow code reuse.
- Example:
int Add(int a, int b) {
return a + b;
}
9. Object-Oriented Programming
- Class: Blueprint for objects.
- Object: Instance of class.
- Concepts: Inheritance, Polymorphism, Encapsulation, Abstraction
13. Collections
- List<T>, Dictionary<K,V>, Stack<T>, Queue<T>
- Example: List<int> nums = new List<int>();
16. Namespaces
- Used to organize code.
- Example: using System;