what is reflection in programming

88

what is reflection in programming -

//Ability to access objects fields/methods (also if they are private)
// in run time (read more about the subjects pro`s and con`s before impl)

// 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);

Comments

Submit
0 Comments