发现了个c# 的 bug
最近写接口的时候发现异常如下, 大家看看是不是bug
using System;
namespace ConsoleApplication1
{
interface A
{
void test(string s);
}
interface B : A
{
void test2(string s);
}
class C : B
{
public void test(string s)
{
Console.WriteLine(s);
}
public void test2(string s)
{
Console.WriteLine(s);
}
}
class Program
{
static void Main(string[] args)
{
string str = "here is a string";
dynamic str2 = str;
B instance = new C();
instance.test2(str); //正常
instance.test2(str2); //正常
instance.test(str); //正常
try
{
instance.test(str2); //异常
}
catch (Exception e)
{
Console.WriteLine(e.Message);
}
Console.ReadLine();
}
}
}