Câu hỏi phỏng vấn C#
Câu hỏi

What is Reflection in C#.Net?

Câu trả lời

Reflection in C# is a powerful feature that allows a program to inspect and manipulate its own metadata at runtime. It provides a way to dynamically access information about types, methods, fields, and properties, and even create new types or invoke methods at runtime[1][2][3].

The key aspects of C# reflection are:

  • It uses the System.Reflection namespace which contains classes like Assembly, Type, MethodInfo, FieldInfo, PropertyInfo, etc. to access metadata[1][2][3]
  • The Type class is the primary way to access metadata. It provides methods and properties to get information about a type declaration[3]
  • Reflection allows creating new types and executing actions using those types at runtime[1]
  • It enables late binding to methods and properties[1]
  • Attribute information can be accessed at runtime using reflection[1]

Some common use cases of reflection in C# include:

  • Inspecting and instantiating types in an assembly at runtime[4][5]
  • Invoking methods and accessing fields and properties dy...
middle

middle

Gợi ý câu hỏi phỏng vấn

middle

What is the difference between Virtual method and Abstract method?

senior

Can you explain the difference between Interface , abstract class, sealed class, static class and
partial class in C#?

junior

What is the difference between a Struct and a Class in C#?

Bình luận

Chưa có bình luận nào

Chưa có bình luận nào