Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR CSHARP

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);
Source by en.wikipedia.org #
 
PREVIOUS NEXT
Tagged: #reflection #programming
ADD COMMENT
Topic
Name
1+6 =