Ternary operator VB vs C#: why resolves Nothing to zero? [duplicate]

This is because VB’s Nothing is not a direct equivalent to C#’s null.

For example, in C# this code will not compile:

int i = null;

But this VB.Net code works just fine:

Dim i As Integer = Nothing

VB.Net’s Nothing is actually a closer match for C#’s default(T) expression.

Leave a Comment