I was looking through some legacy code we have and I noticed something that struck me as particularly odd.
Say we have the concrete class TestClass. TestClass implements the interface ITestClass.
What sort of behavior should I expect in the following case, then? (I didn’t realize this was even possible)
Dim testClass as TestClass = Nothing
Try
testClass = New ITestClass
...
End Try
As far as I understand, you would be FORCED to utilize TestClass instead of its interface counterpart.
There’s one special case, where an interface can be instantiated like a class, and it’s related to the CoClassAttribute. See this blog post for details:
Example from the blog post translated to VB: