Quantcast
Channel: VBForums
Viewing all articles
Browse latest Browse all 15263

Could someone explain this reflective programming example?

$
0
0
On Wikipedia, I found this code in a long article concerning a type of programming called reflective programming:

Code:

// Without reflection
Foo foo = new Foo();
foo.PrintHello();

// With reflection
Object foo = Activator.CreateInstance("complete.classpath.and.Foo");
MethodInfo method = foo.GetType().GetMethod("PrintHello");
method.Invoke(foo, null);

All I grasped is that apparently reflective programming is another paradigm. How does the added complexity make the second tidbit of code "reflective" instead of just a more tedious way of invoking a method?

Viewing all articles
Browse latest Browse all 15263


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>