c# - How to dynamically convert a type to a generic type? -
i have string want convert different types- enums. class holding generic type if have type save couldn't find way of how convert dynamically
if(type.isenum) typedvalue = enum.parse(type, value , true); } else { typedvalue = convert.changetype(value,type); } foreach (delegate method in pair.value) { method.dynamicinvoke(new[] { value, typedvalue, time }); }'
i need alter typed value not of type save generic type according type
you can't because generics used when know type @ compile-time. in illustration type
variable represents runtime type.
c# generics
No comments:
Post a Comment