c# - Cast with typeof -
i have type type sometype want cast in runtime
for example want :
var customers = getcustomers() sometype[]    how this?
you cannot use as cast type known @ runtime: expression invalid @ compile-time since you'd have use typeof(t) cannot used as.
what can use though system.convert.changetype(object, type). here second parameter can use typeof(t) , combined control statement can convert input @ runtime correct type.
you should ask whether want though: types known @ runtime leave little use.
Comments
Post a Comment