void F <TFrom, TTo>() where TTo : TFrom; 在B类中改为上面的声明
没用的,我早试过了,这样的话出现的错误信息是: Constraints for explicit interface implementation method are inherited from the base method,so they cannot be specified directly
public void F <TFrom, TTo>() where TTo : TFrom { } 我在.NET 3.5下编译没问题。 你试下这样写 public void F <TFrom, TTo>() where TTo : TFrom,IConvertible { }
我用VS2008TS+SP编译不过,请问你的版本是?
另外我测试时将TFrom改为了Form,因为TForm这个类我没有,但效果应该一样的。
此处用的是泛型,只代表某个具体类型,无需TFrom或From这样的具体类型
怪了,我编译是通过的 看起来是我的ReSharp插件的BUG
原封不动的代码,编译通过环境: Microsoft Visual Studio 2008 Version 9.0.21022.8 RTM Microsoft .NET Framework Version 3.5 SP1
在B类中改为上面的声明
Constraints for explicit interface implementation method are inherited from the base method,so they cannot be specified directly
{ } 我在.NET 3.5下编译没问题。
你试下这样写
public void F <TFrom, TTo>() where TTo : TFrom,IConvertible
{ }
看起来是我的ReSharp插件的BUG
Microsoft Visual Studio 2008
Version 9.0.21022.8 RTM
Microsoft .NET Framework
Version 3.5 SP1