小编tQu*_*lla的帖子

为什么VB编译器在C#没有捕获到接口类型的无效隐式转换?

比较这个C#(小提琴)

public class Program
{   
    public static void Main()
    {
        IFoo test;
        test = new Impl();
        test = new NoImpl();                
    }
}
public interface IFoo {}
public class NoImpl {}
public class Impl : IFoo {}
Run Code Online (Sandbox Code Playgroud)

到这个VB(小提琴).

Public Module Module1
    Public Sub Main()
        Dim test as IFoo
        test = new Impl()
        test = new NoImpl()
    End Sub
End Module

Public Interface IFoo
End Interface

Public Class NoImpl
End Class

Public Class Impl 
    Implements IFoo
End Class …
Run Code Online (Sandbox Code Playgroud)

c# vb.net compiler-errors

1
推荐指数
1
解决办法
117
查看次数

标签 统计

c# ×1

compiler-errors ×1

vb.net ×1