首页 > 其他 > 详细

关于接口使用getType的方法的问题

时间:2014-05-17 22:18:57      阅读:458      评论:0      收藏:0      [点我收藏+]

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中不行呢?

关于接口使用getType的方法的问题,布布扣,bubuko.com

关于接口使用getType的方法的问题

原文:http://www.cnblogs.com/hacker100/p/3733947.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!