For example, there is some well-known user type (its name is in the project), which is cast to the object type.

Is it possible, without sorting the types, to understand which type is actually in object and make a cast to a real type?

  • one
    if you are in compile-time You do not know the type in which you need to deploy - then there is no way. - Grundy
  • through. .GetType() tried? - RusArt
  • 3
    I can not imagine a situation when I need a cast, to a type that I do not know and, accordingly, I do not know what to do with it. Please tell us about the original problem, where did this task come from. - Alexander Muksimov
  • @RuslanArtamonov, so you can only get the type as a string, bring the object to this type will not work - Grundy
  • why ghost? just use dynamic like this dynamic myObj = method.getSomeObject(); - Sublihim

0