User Tools

Site Tools


notes:csharp:reflection

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
Next revision Both sides next revision
notes:csharp:reflection [2017/12/07]
leszek [Attributes]
notes:csharp:reflection [2019/01/31]
leszek [Reflection in C#]
Line 7: Line 7:
   * calling the //GetType// method on an instance to obtain its type at runtime   * calling the //GetType// method on an instance to obtain its type at runtime
   * using the //typeof// operator on a type name to obtain the type at compile time   * using the //typeof// operator on a type name to obtain the type at compile time
 +
 +Example: Get the name of the calling routine:
 +<code csharp>
 +string methodName = new StackTrace().GetFrame(1).GetMethod().Name;
 +</code>
  
 ====GetType and typeof==== ====GetType and typeof====
Line 508: Line 513:
  
 <code csharp> <code csharp>
-// Attribute definition that defines an optional name argument as a public read/write property:+// Attribute definition that defines an optional named argument as a public read/write property:
 public class TestAttribute : System.Attribute public class TestAttribute : System.Attribute
 { {
notes/csharp/reflection.txt ยท Last modified: 2020/08/26 (external edit)