2
Answers

Advantages and Disadvantages in Reflection

Photo of Vamsi k

Vamsi k

6y
11.4k
1
Hi Team,
 
Can anyone please give the advantages and disadvantages of Reflection in C#.
 
Please give your answers in point wise
 
 
Regards,
Vamsi 

Answers (2)

1
Photo of Puneet Kankar
243 8.1k 1.1m 6y
Hi Vamsi.
 
please check below links for better understanding.
The advantage of reflection:
  • you can iterate through the properties and get the value.
  • Custom Attributes can be retrieved.
  • Load an assembly dynamically and create instances.
  • Invoke a particular method.
  • know about Private/Public methods.
Disadvantage:
  • Performance can be hampered a lot.
  • Overhead at runtime.
https://www.programering.com/a/MzN4YTNwATM.html
https://csharp.net-tutorials.com/reflection/introduction/
https://forums.asp.net/t/1785601.aspx?Reflection+advantages+and+disadvantages
https://www.codeguru.com/csharp/csharp/cs_misc/reflection/article.php/c4257/An-Introduction-to-Reflection-in-C.htm
 
0
Photo of Madan Shekar
232 8.3k 1.2m 6y
Advantages: Reflection improves the flexibility and expansibility, reduce the coupling, to improve the adaptive ability. It allows programs to create and control object of any kind, no advance hard coded target class.
 
Disadvantages:
1, performance problems: use reflection to basically is a kind of explanation for operation, field and method access is much slower than direct code. So the system frame reflection mechanism is mainly used in a very high requirements for flexibility and expansibility, ordinary procedure does not recommend the use of.
 
2, The use of reflection will be fuzzy program internal logic: the programmer wants to see the logic of the program in the source code, reflection and bypass the source code technology, which will bring the maintenance problems. Reflection code is more complex than the corresponding direct code.
As for the execution efficiency, also, because it is a strongly typed language, the execution efficiency. However, recommendations will be reflected later, Bao Cunjin cache.
 
Thanks, Hope it will help you..