Types problem?

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I create an object "A" dynamiclly using Emit, I tryed to cast ti "A" the obtained object and it throw a cast exception
I saw that as strings the types are the same but the follow condition return false
if (typeof(A) == objectObtainedDynamicly.GetType
return true
return false
 
ya1000 said:
I create an object "A" dynamiclly using Emit, I tryed to cast ti "A"
the obtained object and it throw a cast exception.
I saw that as strings the types are the same but the follow condition
return false:
if (typeof(A) == objectObtainedDynamicly.GetType)
return true;
return false;

As I said this morning, please produce a short but complete example.
The above is somewhat bizarre, as typeof(A) can only work when the type
A exists at compile time - so why are you generating another type with
the same name?
 
I gave up trying to compare this way, I convert types to their string names;

if (typeof(A).ToString() == objectObtainedDynamically.GetType().ToString())
{}


-ilpostino

ya1000 said:
I create an object "A" dynamiclly using Emit, I tryed to cast ti "A" the
obtained object and it throw a cast exception.
 
Back
Top