我想像这样在c#中的泛型中使用带有类型参数的类型参数:
const scArr = Array.from($('.slider'));
scArr.forEach(el => $(el).roundSlider({
radius: 80,
circleShape: "half-left",
sliderType: "min-range",
showTooltip: false,
value: 150,
width: 10,
min: 0,
max: 200,
update: function (args) {
$('.value').html(`${args.value} %`);
}
}));
有可能这样做吗?
答案 0 :(得分:0)
尝试了许多事情之后,即使使用where
子句,您似乎仍然无法完成:编译器拒绝所有T<ClassB>
和IList<T1<T2>>
。
https://docs.microsoft.com/en-us/dotnet/csharp/misc/cs0307
示例:
public class ClassA<T1, T2> : IList<T1<T2>> // implementation request refused
where T2 : ClassB
{
}
public class ClassA<T, T1, T2> : IList<T>
where T : T1<T2> // constraint refused
where T2 : ClassB
{
}
不能将参数类型为T1的参数与
一起使用
能够做这样的事情可能很有趣。