Tangible Software Solutions
The Most Trusted Name in Source Code Conversion
VB uses the 'CreateObject' function to acquire a type instance at run-time where the type is unknown at compile time. VB then allows invoking members of this instance even though the type is unknown at compile time (this requires the VB Option Strict setting to be turned off). C# allows the same behavior via the 'dynamic' keyword and a call to System.Activator.CreateInstance:
Dim o As Object = CreateObject(progID)
o.Foo() 'late-bound call to 'Foo' method
dynamic o = System.Activator.CreateInstance(System.Type.GetTypeFromProgID(progID));
o.Foo(); //late-bound call to 'Foo' method
If you need to convert from VB to C# and you are depending on the results being reliable and accurate, then you will want to have Instant C#, the best VB to C# converter, at your fingertips.
Copyright © 1997 - 2017 Tangible Software Solutions Inc.