我正在写做一个铸件的方法,我需要收到类型放慢参数,例如:如何接收类型作为参数?
object foo(?? type, object input) {
if(type is x) {
Output output = new Output();
x xValue = (x) input;
foreach(var val xValue) {
//do..
}
return output;
}
if(type is y) {
Output2 output = new Output2();
y yValue = (y) input;
foreach(var val yValue) {
//do..
}
return output;
} else {
//invalid type
}
}
为解决这个问题不同的方式表示赞赏太:)
在此先感谢。
类型为'系统。键入'或键入特定(或继承)类型的对象? –
类型为'CookieCollection','CookieContainer' .. – Jack