This is an archived thread from the StopByte developer forum —
browse all archived threads.
StopByte is now a payments & ecommerce toolkit — check out our
free calculators.
public class SampleClass
{
public string SampleMember {get;set;}
public void SampleMethod(string param1)
{
// Does something here.
}
}
The SampleClass above has two members, SampleMember (property) and SampleMethod. Now is there any way i can Retrieve list of methods,and classes that are Referencing my Method and my Sample Member in C# using Reflection?
thanks
ivan.norin
(ivan.norin)
#2
You want get all methods in your class?
using System;
using System.Reflection;
using System.Reflection.Emit;
Type myType =(typeof(SampleClass));
// Get the public methods.
MethodInfo[] myArrayMethodInfo = myType.GetMethods(BindingFlags.Public|BindingFlags.Instance|BindingFlags.DeclaredOnly);
Console.WriteLine("\nThe number of public methods is {0}.", myArrayMethodInfo.Length);