C# Language Overload Resolution Passing null as one of the arguments

Help us to keep this website almost Ad Free! It takes only 10 seconds of your time:
> Step 1: Go view our video on YouTube: EF Core Bulk Extensions
> Step 2: And Like the video. BONUS: You can also share it!

Example

If you have

void F1(MyType1 x) {
    // do something
}

void F1(MyType2 x) {
    // do something else
}

and for some reason you need to call the first overload of F1 but with x = null, then doing simply

F1(null);

will not compile as the call is ambiguous. To counter this you can do

F1(null as MyType1);


Got any C# Language Question?