Is there a VB.NET equivalent to the C# 7 is operator declaration pattern? Note in particular the bmp
in the following code sample:
public void MyMethod(Object obj)
{
if (obj is Bitmap bmp)
{
// ...
}
}
Or the short pattern matching syntax with is
is exclusive to C#?
EDIT:
I already know these syntaxes:
If TypeOf obj Is Bitmap Then
Dim bmp As Bitmap = obj
' ...
End If
or
Dim bmp As Bitmap = TryCast(obj, Bitmap)
If bmp IsNot Nothing Then
' ...
End If
What I want to know is whether there is something even shorter, like that new C#7 is operator declaration pattern...
Thank you very much.
Though C# and VB.NET are syntactically very different, that is where the differences mostly end. Microsoft developed both of these languages to be part of the same . NET Framework development platform. They are both developed, managed, and supported by the same language development team at Microsoft.
You are right, C++ and VB are two completely different languages and have quite a few fundamental differences (managed vs. unmanaged being a major one that comes to mind...).
It is a fact that coding languages never die. Even the oldest coding languages such as Classic Asp, VB6, COBOL, FORTRAN, VB.Net, etc. are still in use in few organizations.
Visual Basic (VB.NET) will continue to be supported by Microsoft. (It's not dead.) The language will no longer have new features added to it.
Currently, no. If you want to implement this, you'll have to use some of the longer formats you already mention in your question.
The C# and VB languages don't always have equivalent features.
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