Advanced Development Exam Notes
1. CLR (Common Language Runtime)
Definition:
The CLR is the heart of the .NET Framework. It manages program execution and provides core services.
Key Responsibilities:
- Memory Management (Garbage Collection)
- Code Safety & Type Checking
- Exception Handling
- Just-In-Time (JIT) Compilation
- Security & Access Control
Example:
You write C# code -> CLR compiles to MSIL -> JIT converts MSIL to machine code.
class Program {
static void Main() {
Console.WriteLine("Hello from CLR");
}
}
Advanced Development Exam Notes
2. Managed vs Unmanaged Code
Managed Code:
- Runs under CLR.
- Secure with automatic memory management.
- Written in .NET languages.
Unmanaged Code:
- Runs outside CLR (e.g., C/C++), manual memory management.
Example:
Managed (C#): string name = "Alice";
Unmanaged (C++): char* name = (char*)malloc(10);
Advanced Development Exam Notes
3. Object-Oriented Programming in C#
OOP Pillars:
- Encapsulation: Hide internal state using private variables.
- Abstraction: Show only essential features.
- Inheritance: Child inherits from parent.
- Polymorphism: Method acts differently via overloading/overriding.
Example:
class Animal {
public virtual void Speak() { Console.WriteLine("Sound"); }
}
class Dog : Animal {
public override void Speak() { Console.WriteLine("Bark"); }
}
Advanced Development Exam Notes
4. Constructors
Types:
- Default: No parameters.
- Parameterized: Accepts arguments.
- Static: Runs once per type.
Example:
class Car {
public string Model;
public Car() { Model = "Default"; }
public Car(string m) { Model = m; }
static Car() { /* Runs once */ }
}
Advanced Development Exam Notes
5. Method Overloading & Overriding
Overloading:
Same method name, different parameters.
int Add(int a, int b);
double Add(double a, double b);
Overriding:
Base method is virtual, derived overrides with override.
class A { public virtual void Show() {} }
class B : A { public override void Show() {} }
Advanced Development Exam Notes
6. Arrays and Reverse Method
Definition:
Fixed-size collection of same-type data.
Example:
int[] arr = {1, 2, 3};
Array.Reverse(arr);
Advanced Development Exam Notes
7. Sorting Algorithms
Merge Sort:
Divide, sort, and merge. O(n log n)
Selection Sort:
Find min and swap with current. O(n²)
for (int i = 0; i < n; i++) {
int min = i;
for (int j = i+1; j < n; j++) {
if (arr[j] < arr[min]) min = j;
}
// Swap
}
Advanced Development Exam Notes
8. Cross-Platform Development
Definition:
Build apps for Windows, Linux, macOS using one codebase.
Technologies:
- .NET Core / .NET 5+ (web, console)
- Xamarin / MAUI (mobile)
- Blazor (web UI using C#)
Command:
dotnet new console -o MyApp
dotnet run
Advanced Development Exam Notes
9. Testing in .NET
Types:
- Unit Testing: Individual functions.
- Integration Testing: Combined components.
- System Testing: Entire application.
- Automated Testing: Tests in code.
Frameworks: MSTest, xUnit, NUnit
Example (xUnit):
[Fact]
public void TestAdd() {
Assert.Equal(5, 2 + 3);
}
Advanced Development Exam Notes
10. Application Lifecycle Management (ALM)
Definition:
End-to-end management of app lifecycle.
Phases:
1. Requirement Analysis
2. Design
3. Development
4. Testing
5. Deployment
6. Maintenance
Tools: Azure DevOps, GitHub Actions, Jira