Possible Duplicates:
When do you use reflection? Patterns/anti-patterns
What exactly is Reflection and when is it a good approach?
What is the need for reflection in .NET? What are the situations where it comes in handy?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Let’s say you’re writing a basic serialization routine, that will serialize any object to XML. How would you make it generic enough, so that it can work for any object? If you have a class where you know all the properties, then you can easily write a “ToXml()” function, where you manually write out all the properties to XML. What if you want to extend this though to ANY object? In that case, you need to reflect over the properties at runtime, and write them out to the XML.
There are many more uses for it, that’s the first one that came to mind.