Calling a method on a generic base class created with Activator.CreateInstance?

A priori, you know nothing about the common features that might exist between GenericBase.

A priori, you know nothing about the common features that might exist between GenericBase and GenericBase. It's possible they have nothing in common. So without knowing the type of the parent generic class, you actually don't know anything useful at all about the object.

Now, on the other hand, it's clear that what you're saying in this particular example is that there is something in common between GenericBase and GenericBase -- they both implement the non-generic void Foo(string s). So to be able to do something useful with your object, you need to formalize this behavior; put Foo into a non-generic IFoo interface, and have GenericBase implement the interface. Then you can cast your object to an IFoo, and call Foo.

I thought of interfaces, but didn't mention this is my question. It might be the most elegant solution. – Mike Thompson Jun 18 '09 at 4:26 It is.

You might be interested in this Eric Lippert blog entry on the topic of generic "mumble types" (his coined word for references to generic types where you don't care about the generic part of the type right now:) blogs.msdn. Com/ericlippert/archive/2008/05/19/… – mquander Jun 18 '09 at 6:24 In my real code the Foo method is generic (it instantiates a T object -- it does not have any parameters of T or return a T). So the interface technique works even though Foo is generic.

– Mike Thompson Jun 18 '09 at 12:25.

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