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

expert

Could you explain the difference between destructor , dispose and finalize method?

junior

Why to use finally block in C#?

senior

What is the use of conditional preprocessor directive in C#?

Bình luận

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

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