How do I creating Generic object from dynamically loaded Type?

If the real goal is to create an ActiveRecordMakeGenericType or MethodInfo. MakeGenericMethod depending on the ActiveRecord API (which I'm not familiar with)... but you're not going to be able to use the result in a statically typed way (that depends on T) in the lines of code which follow Does ActiveRecord.

Your class must inherit ActiveRecord or by itself be ActiveRecord . You are trying to cast a type into another object receving the fomer as varible: Cat c = new Cat(); List l = (List) c; // error.

The point of static typing is that you know the type at compile time. What do you expect the type of the record variable to be? The compiler needs to know - it can't wait until execution time.

What do you want to do with record anyway? If the real goal is to create an ActiveRecord object but you don't need to know the T for any other operations, then you'll need to use reflection with Type. MakeGenericType or MethodInfo.

MakeGenericMethod depending on the ActiveRecord API (which I'm not familiar with)... but you're not going to be able to use the result in a statically typed way (that depends on T) in the lines of code which follow. Does ActiveRecord implement a nongeneric interface? If so, that's what you'd usually use after constructing the relevant instance.

If you can provide a link to ActiveRecord documentation to show how to construct an instance, I'm happy to write the reflection code for you...

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions