Chaman Zinga

hi guys,

now i have a code which instantiates class

but the thing is i want to instantiate an interface which calls the method from different classes, now my code is just calling one method from only one class.

the requirement is there are 'n' number of classes,

each has a method with same name say " shoot()"

i have implemented this method in interface also,

this is the code which instantiates class and calls "shoot()" from that class.

if (type.IsClass == true)


// doing it this way means that you don't have

// to specify the full namespace and class (just the class)

if (type.FullName.EndsWith("." + ClassName))


DynaClassInfo ci = new DynaClassInfo(type, Activator.CreateInstance(type));

ClassReferences.Add(AssemblyName, ci);

return (ci);



//DynaClassInfo is a class.

what i want is to instantiate an interface and call the same method from that interface.

Re: Visual C# Language how to instantiate interface

Paul Louth

You can't instantiate an interface. And even if you could, there's no implementation to execute, so it's pointless.