CSharp examples for Reflection:Method
Get Try Parse Method Info
using System.Threading.Tasks; using System.Text.RegularExpressions; using System.Text; using System.Reflection; using System.Linq; using System.ComponentModel; using System.Collections.Generic; using System;/*from w ww. j a va 2 s . c o m*/ public class Main{ static MethodInfo GetTryParseMethodInfo(Type numericType) { MethodInfo method = null; if (numericType == typeof(int) || numericType == typeof(byte) || numericType == typeof(float) || numericType == typeof(double) || numericType == typeof(decimal)) { var methodInfos = numericType.GetMember("TryParse", MemberTypes.Method, BindingFlags.Public | BindingFlags.Static); if (methodInfos.Length > 0) { foreach (MethodInfo mi in methodInfos) { if (mi.GetParameters().Length == 2) { method = mi; break; } } } } return method; } }