Recall & Review
beginner
What is reflection in C#?
Reflection is a feature in C# that allows a program to inspect and interact with its own structure, such as types, methods, and properties, at runtime.
Click to reveal answer
beginner
Why do we need reflection in programming?
Reflection is needed to dynamically discover information about objects and types during program execution, enabling flexible and reusable code without knowing all details at compile time.
Click to reveal answer
beginner
Give a real-life example where reflection is useful.
Imagine a plugin system where new features are added without changing the main program. Reflection helps the program find and use these new features dynamically at runtime.
Click to reveal answer
intermediate
How does reflection help with serialization?
Reflection allows a program to examine object properties and fields at runtime, making it possible to convert objects to formats like JSON or XML without hardcoding each type.
Click to reveal answer
intermediate
What is a potential downside of using reflection?
Using reflection can slow down the program because it works at runtime and bypasses some compile-time optimizations. It can also make code harder to understand and maintain.
Click to reveal answer
What does reflection allow a C# program to do?
✗ Incorrect
Reflection lets a program look at its own types and members while running.
Which scenario best shows why reflection is needed?
✗ Incorrect
Reflection helps load and use new code dynamically, like plugins.
What is a common use of reflection in serialization?
✗ Incorrect
Reflection reads object details to convert them into formats like JSON.
What is a drawback of using reflection?
✗ Incorrect
Reflection works at runtime and can slow down the program.
Reflection is mainly used to:
✗ Incorrect
Reflection accesses type and member info while the program runs.
Explain why reflection is important in C# programming and give an example of its use.
Think about how programs can adapt without knowing everything beforehand.
You got /3 concepts.
Describe one advantage and one disadvantage of using reflection.
Reflection helps with flexibility but can slow down the program.
You got /3 concepts.