[导入]关于接口使用getType的方法的问题

it2025-03-23  24

C#代码如下:    public interface IConfigInfo    {    }    public class A : IConfigInfo    {

    }    public class b    {        void bb(IConfigInfo a)        {            Type t = a.GetType();        }    }

VB.net代码如下: Public Interface IConfigInfo End Interface Public Class A     Implements IConfigInfo     End Class Public Class b     Private Sub bb(ByVal a As IConfigInfo)         Dim t As Type = a.GetType()     End Sub End Class 请大家注意红色部分,其中C#代码运行正常,而vb的哪个就是不行,错误原因为: a.GetType() 提示:GetType不是IConfigInfo 的成员 园子里的筒子:沙加说: 把a 先转成object试试.----Dim t As Type = ctype(a,object).GetType() ---这样子竟然行了。。。。极度郁闷,为什么c#中可以用a.gettype()来获取对象类型,而在vb中不行呢? 没剑 2007-12-27 16:38 发表评论 [小组]   [博问]   [闪存] 文章来源: http://www.cnblogs.com/regedit/archive/2007/12/27/1017170.html

转载于:https://www.cnblogs.com/HappyQQ/articles/1017673.html

最新回复(0)