Cast with reflection

Hello

How I can cast something using reflection

Example:



String typ = "TextBox";

(Reflection(typ))MyClass = (Reflection(typ))PointerClass.GetData();

 


MyClass should be a TextBox class with the Instance in the PointerClass.GetData() saved Data.

Thanks
Tony


Answer this question

Cast with reflection

  • Dick Roose

    Tony,

    Your question is not very clear. The way you are using Reflection is like a keyword - and I there is no Reflection keyword in C#. 

    if PointerClass.GetData is returning a type TextBox/Object then you don't need reflection you can directly cast it

    TextBox MyClass = (TextBox)PointerClass.GetData();

    If that's not the case, please elobrate what you are trying to acheive.

    Regards,
    Saurabh Nandu
    www.MasterCSharp.com
    www.AksTech.com

  • Cast with reflection