C# Reflection: How to call method of interface without creating instance?
Posted
by jitm
on Stack Overflow
See other posts from Stack Overflow
or by jitm
Published on 2010-05-07T13:39:17Z
Indexed on
2010/05/07
13:48 UTC
Read the original article
Hit count: 161
c#
Hello, I have situation where I have to call method of interface using reflection, like this
object x = null;
MethodInfo method = interfaceExists.GetMethod("ShutDown");
method.Invoke(x, new object[] { 4 })
As you can see I do not create instance of object! And, as I can supposed, I receive exception
Non-static method requires a target
And Question, Can I call method of interface using reflection without creating instance of interface and if YES, How I can do it ? Thank you.
© Stack Overflow or respective owner