T
Thomas
Hello all,
How do I determine if conversion (implicit or explicit) between integral
types exists?
I tried using Type.IsAssignableFrom() method but with no satisfactory
results.
Example below.
I want to determine in code if certain assignments, like: float f = 0; int i
= 0; f=i;
are allowed or not, and which require explicit conversion (i=(int)f
.
Thanks for any hints.
Thomas
Type t1 = typeof(int);
Type t2 = typeof(float);
Type t3 = typeof(bool);
Console.WriteLine(t2.IsAssignableFrom(t1));
Console.WriteLine(t1.IsAssignableFrom(t3));
How do I determine if conversion (implicit or explicit) between integral
types exists?
I tried using Type.IsAssignableFrom() method but with no satisfactory
results.
Example below.
I want to determine in code if certain assignments, like: float f = 0; int i
= 0; f=i;
are allowed or not, and which require explicit conversion (i=(int)f
![Wink ;) ;)](/styles/default/custom/smilies/wink.gif)
Thanks for any hints.
Thomas
Type t1 = typeof(int);
Type t2 = typeof(float);
Type t3 = typeof(bool);
Console.WriteLine(t2.IsAssignableFrom(t1));
Console.WriteLine(t1.IsAssignableFrom(t3));