using System.Reflection; ... MethodInfo myMethod = typeof(MyClass).GetMethod("MyMethod"); string methodString = myMethod.ToString(); Console.WriteLine(methodString);
using System.Reflection; ... PropertyInfo myProperty = typeof(MyClass).GetProperty("MyProperty"); string propertyString = myProperty.ToString(); Console.WriteLine(propertyString);This example creates a PropertyInfo object for a property named "MyProperty" in a class called "MyClass", and then calls the ToString method on the object to get a string representation of the property. This outputs the following string: "System.String MyClass.MyProperty { get; set; }". This method also belongs to the System.Reflection package library.