cIn C# there is a null conditional operator ?. (sometimes called the Elvis operator) like so:
var name = project?.customer?.name;
which doesn't fail but instead return null if project or customer is null.
Is there an equivalent in VB.NET?
Note that I am not looking for If(b, x, y) but the very ?. replacement.
VB also has the null conditional operator (never heard the term 'Elvis' operator):
Dim name = customer?.name
Notes:
Inferred typing in VB requires 'Option Infer On'
I'm pretty sure that your original C# code sample should have been: var name = customer?.name;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With