4
所以,情况是我有一个C#泛型类名为Foo
与模板参数T
其中有new()
约束。我宣布我的课是这样的:C#泛型与IronPython类型参数
class Baz
{
public Baz() { }
}
class Foo<T>
where T : Baz, new()
{
// blah blah
}
而且在Python:
class Bar(Baz):
def __init__(self):
""" do various things here """
然而,如果在Python中,我尝试做Foo[Bar]
,我得到一个错误,告诉我,我的Bar
类违反约束条件(即new()
约束条件)Foo<T>
。
什么给?
嗯,是的,当我意识到模板实际上放弃了我所有的Python类型信息时,我就是这么想的。感谢您的确认。 – rfw 2010-09-26 22:19:56
有人可以详细说明或举例说明吗?我对python内部工作的认识并不能帮助我跳到代码中应该看到的东西。 – Gauthier 2013-07-23 13:25:30
我只是试了几件事,发现C#函数 somefunc(字符串x){dostuff(); } 必须调用为 somefunc [sometype](“some string”) –
Gauthier
2013-07-23 13:38:21