我正在寫做一個鑄件的方法,我需要收到類型放慢參數,例如:如何接收類型作爲參數?
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