It's a simple concept, but one I've never been taught. Can someone please explain the differences between the following 2 statements please:
Dim c as MyClass
Dim c as New MyClass
Dim c as New MyClass is a shortcut and strictly equivalent to the following:
Dim c as MyClass = New MyClass
Both are different to Dim c as MyClass: the statement without New only declares the variable, it doesn’t assign a value. This means that the variable has a default value of Nothing.
New MyClass, on the other hand, assigns a newly-created instance of that class to the variable.
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