C# Advanced Features - Complete Explanation

This code demonstrates several important C# features introduced in C# 3.0 and later versions. Let's explore each concept in detail.

1. Partial Classes

Theory

Partial classes allow you to split the definition of a class across multiple source files. This is particularly useful for:

Key Rules

Example Implementation

// File: MathsOperations.cs
public partial class Maths
{
    public int Add(int a, int b)
    {
        return a + b;
    }
}

// File: MathsAdvanced.cs
public partial class Maths
{
    public int Sub(int a, int b)
    {
        return a - b;
    }
}

2. Implicit Type Declaration (var keyword)

Theory

The var keyword enables implicit type declaration where the compiler infers the type from the right-hand side of the assignment. This feature provides: