14 questions for “Attributes & Reflection”

Found in 1 field. Select a question to see its full answer.

Information Technology

14 questions in 1 technology

#QuestionTechnologyTopicLevel
1How does the .NET dependency injection container and ASP.NET Core's model binding use reflection and attributes together under the hood? C# › Attributes & ReflectionC#Attributes & ReflectionAdvanced
2What is reflection in C#, and what are its most common practical uses and performance trade-offs? C# › Attributes & ReflectionC#Attributes & ReflectionIntermediate
3What is reflection, and what basic information can you retrieve from a Type object at runtime? C# › Attributes & ReflectionC#Attributes & ReflectionBeginner
4How do you use reflection to read a custom attribute's values off a property at runtime? C# › Attributes & ReflectionC#Attributes & ReflectionIntermediate
5How do you dynamically create an instance of a type and invoke a method on it using reflection, when the type isn't known at compile time? C# › Attributes & ReflectionC#Attributes & ReflectionIntermediate
6How would you write a simple reflection-based object mapper that copies matching property values from one object to another of a different type? C# › Attributes & ReflectionC#Attributes & ReflectionAdvanced
7How do you use reflection to discover all types in an assembly that implement a specific interface, useful for plugin discovery? C# › Attributes & ReflectionC#Attributes & ReflectionAdvanced
8Why is reflection generally slower than direct code, and what techniques (like caching or compiled expressions) mitigate this cost? C# › Attributes & ReflectionC#Attributes & ReflectionAdvanced
9How would you use System.Reflection.Emit or source generators as faster, more modern alternatives to runtime reflection for code generation scenarios? C# › Attributes & ReflectionC#Attributes & ReflectionAdvanced
10What is an attribute in C#, and how do you apply one to a class or method? C# › Attributes & ReflectionC#Attributes & ReflectionBeginner