R
Rickard
I want to dynamically check if I can assign from type A to type B in
runtime. Type.IsAssignableFrom does not work for me as,
typeof(int).IsAssignableFrom(typeof(short))
returns false, which is incorrect in the (english) meaning of "Is
assignable from".
Is there a function that checks if the assignment will throw an
InvalidCastException?
Simply using
try {
} catch (InvalidCastException) {}
does not work either because I don't want to do the actual assignment,
but do different processing depending on if the types CAN be assigned.
Thanks in advance for any help/suggestions.
/ Rickard
runtime. Type.IsAssignableFrom does not work for me as,
typeof(int).IsAssignableFrom(typeof(short))
returns false, which is incorrect in the (english) meaning of "Is
assignable from".
Is there a function that checks if the assignment will throw an
InvalidCastException?
Simply using
try {
} catch (InvalidCastException) {}
does not work either because I don't want to do the actual assignment,
but do different processing depending on if the types CAN be assigned.
Thanks in advance for any help/suggestions.
/ Rickard