1
Answer

How to get Class Object from Type.

HHk

HHk

16y
2k
1
 

Dear Frends

I have some situation like this:

 

Type blType;

blType = pi.PropertyType.GetGenericArguments().First();  //this gives me the type of object.

 

Now i have a generic method,to which i have to pass the class of this blType Object.

 

Like for example :

pi.SetValue(objectBL, GetObjects<AddressBL>(objectDL,true), null);

 

Now when i do this

 

pi.SetValue(objectBL, GetObjects<bltype>(objectDL,true), null); //when i do this it throws error saying "The type or namespace name 'bltype' could not be found (are you missing a using directive or an assembly reference?) "..Obviously we need to send the Class object to it..

pls let me know how can we get Class Object from Type. I am sure i am missing some concept.

Note we have in Java2.

 Class c = int.class;
or Class c = Integer.TYPE;

 

help.

Thanks

Answers (1)