我正在尝试使用 3.5 框架将以下代码从 C# 转换为 Vb。
这是我遇到问题的 C# 代码。
MethodInfo mi = typeof(Page).GetMethod("LoadControl", new Type[2] { typeof(Type), typeof(object[]) });
我以为在VB中会是这样;
Dim mi As MethodInfo = GetType(Page).GetMethod("LoadControl", New Type(2) {GetType(Type), GetType(Object())})
但我收到以下错误“数组初始化程序缺少 1 个元素”
我遇到问题并遇到相同错误的另一行是
control = (Control) mi.Invoke(this.Page, new object[2] { ucType, null });
我在vb中尝试过,但它不起作用。
control = DirectCast(mi.Invoke(Me.Page, New Object(2) {ucType, Nothing}), Control)
ucType 定义如下
Dim ucType As Type = Type.[GetType](typeName(1), True, True)
任何帮助将不胜感激。