1. Fundamentals & Data Types
1. C# Introduction & Setup
What is C#?
.NET Ecosystem Overview
.NET Framework (2002-present) → Windows only, legacy
.NET Core (2016-2020) → Cross-platform, modern
.NET 5/6/7/8/9 (2020-present) → Unified platform, recommendedInstalling Development Tools
First Program Structure
Comments
2. Identifiers & Variables
Naming Rules (Enforced by Compiler)
Naming Conventions (Best Practices)
Type
Convention
Example
Variable Declaration Patterns
var Keyword (C# 3.0+)
dynamic Keyword (C# 4.0+)
Constants: const vs readonly
const - Compile-Time Constant
readonly - Runtime Constant
Feature
const
readonly
Literals
3. Data Types Deep Dive
Value Types vs Reference Types
Built-in Value Types Table
Integral Types
Type
Size (bytes)
Range
Default
Suffix
.NET Type
Floating-Point Types
Type
Size (bytes)
Precision
Range
Default
Suffix
.NET Type
Other Value Types
Type
Size (bytes)
Values
Default
.NET Type
String Type (Reference Type!)
String vs string
String Immutability
String Interpolation (C# 6.0+)
Verbatim Strings (C# 1.0+)
Raw String Literals (C# 11.0+)
Object Type (The Universal Base)
Type Hierarchy Diagram
4. Nullable Types
Problem: Value Types Can't Be Null
Nullable Value Types (C# 2.0+)
Working with Nullable Types
Null-Coalescing Operator (??) - C# 2.0+
Null-Coalescing Assignment (??=) - C# 8.0+
Null-Conditional Operator (?.) - C# 6.0+
Nullable Reference Types (C# 8.0+)
5. Enums
Enum Declaration and Usage
Explicit Values
Underlying Types
Flags Attribute [Flags]
Enum Methods
Bitwise Operations with Enums
6. Type Casting & Conversion
Implicit vs Explicit Casting
Cast Operator: (type)
as Operator
is Operator
typeof Operator
Parse vs TryParse
Convert Class Methods
Boxing and Unboxing
7. Operators
Arithmetic Operators
Operator
Name
Example
Result
Comparison Operators
Operator
Name
Example
Result
Logical Operators
Operator
Name
Example
Description
Bitwise Operators
Operator
Name
Example
Description
Assignment Operators
Operator
Example
Equivalent to
Null Operators
Operator
Name
Example
Description
Other Operators
Operator
Name
Example
Description
Operator Precedence (High to Low)
Level
Operators
Associativity
8. Scope of Variables
Local Scope (Method)
Class Scope (Fields)
Block Scope
Parameter Scope
Static Scope
Variable Shadowing (Hiding)
Scope Type
Declared
Lifetime
Access
9. params Keyword
Variable-Length Arguments
Traditional params with Arrays (C# 1.0+)
Rules for params
params with Span<T> (C# 12.0+)
params with Collections (C# 13.0+)
Real-World Examples
Quick Reference Tables
Data Types Quick Reference
Category
Type
Size
Range
Default
Use Case
Type Conversion Methods
Scenario
Method
Example
Operator Quick Reference
Category
Operators
Example
Variable Declaration Patterns
Common Pitfalls
1. Integer Division
2. String Immutability
3. Boxing Overhead
4. Nullable Value Access
5. == vs Equals for Strings
6. Forgetting Suffix for Literals
7. Overflow Without Checking
8. Confusing = and ==
Best Practices
1. Use Meaningful Names
2. Use var Judiciously
3. Prefer Explicit Types for Primitives
4. Use const for True Constants
5. Use Nullable Reference Types (C# 8.0+)
6. Use TryParse Instead of Parse
7. Use Proper Numeric Types
8. Be Careful with Floating-Point Comparison
9. Initialize Variables
10. Use String Interpolation (C# 6.0+)
Last updated