我有这个课程:
interface Info{}
class AInfo : Info { }
class BInfo : Info { }
class SendInfo {
static public f_WriteInfo(params Info[] _info) {
}
}
class Test {
static void Main() {
SendInfo.f_WriteInfo(
new[] {
new AInfo(){ ... },
new BInfo(){ ... },
} );
// This will generate an error.
// There will be need casting between new and [] like new Info[]
}
}
有没有办法做到这一点而不铸造?
像:
class SendInfo {
static public f_WriteInfo(params T _info) where T : Info {