Is there an equivalent for the C# 4 'dynamic' keyword when using type safe VB.NET, i.e. with Option Strict On
?
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.
Operators are symbols that are used to perform operations on operands. Operands may be variables and/or constants. For example, in 2+3 , + is an operator that is used to carry out addition operation, while 2 and 3 are operands. Operators are used to manipulate variables and values in a program.
It is enharmonically equivalent to D-flat major. Its key signature has seven sharps.
The equivalent is Object in VB.NET but with Option Strict Off
. With Option Strict On
there's no equivalent. Put another way the dynamic keyword brings Option Strict Off
equivalent functionality to C#.
VB.NET always had the "dynamic" feature built in, originally called late binding. This syntax was supported forever:
Dim obj = new SomeComClass() obj.DoSomething()
Worked on code implemented in .NET and COM, the latter being the most common use. The dynamic keyword in C# gave it that same capability. It did get changed in VB.NET version 10 however, it is now using the DLR as well. Which adds support for dynamic binding to language implementations like Python and Ruby.
The syntax is exactly the same, use the Dim keyword without As. You will however have to use Option Strict Off
, Option Infer On
can soften that blow a bit. It does show that C# using a specific keyword to signal dynamic binding was a pretty good move. Afaik all requests to do so in VB.NET as well have as yet been considered but not planned.
If you prefer Option Strict On
, then using the Partial Class
keyword so you can move some of the code into another source file is probably the most effective approach.
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