What is reflection ? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 4

What is reflection ?

what is its practical use?

14th Apr 2017, 5:57 PM
Mayur Phanse
Mayur Phanse - avatar
2 Answers
+ 22
By using Reflection in C#, one is able to find out details of an object, method, and create objects and invoke methods at runtime. The System.Reflection namespace contains classes and interfaces that provide a managed view of loaded types, methods, and fields, with the ability to dynamically create and invoke types :-D
14th Apr 2017, 6:04 PM
Dev
Dev - avatar
+ 1
Let me illustrate with an example: For example you want to execute code that you don't know what it is before compilation. The user decides. C# not only supports that but also have dynamic keyword with which you can simply use dynamic features of C# without using reflection. It's lot more easier to work with.
29th Apr 2017, 7:59 PM
Amir Pourmand
Amir Pourmand - avatar