Getting a Type variable knowing the name of type C#

Posted by StuffHappens on Stack Overflow See other posts from Stack Overflow or by StuffHappens
Published on 2010-06-10T10:28:48Z Indexed on 2010/06/10 10:32 UTC
Read the original article Hit count: 159

Filed under:
|

Hello!
I'm developing a TypeTranslator class which has a method Type TranslateType(Type type). This method gets a type of an interface and if there's a class of interface name without leading I it creates it, otherwise an exception is raised.
Here's some code to clearify what's written before:

class Program
{
    interface IAnimal { }
    class Animal : IAnimal { }

void Function()
{
    TypeTranslator typeTranslator = new TypeTranslator();
    Assert(typeTranslator.TranslateType(typeof(IAnimal) == typeof(Animal)));
}

}

Is it possible to get what I want?
Thank you for your help!

© Stack Overflow or respective owner

Related posts about c#

Related posts about reflection