Reputation: 907
I have strings with a math function names. E.g. Sin, Abs, Max ...
How can I call for example Math.Sin(arg) in a way where I can specify the Sin part based on a variable?
Upvotes: 2
Views: 468
Reputation: 2501
You Can use reflection
var concreteType = typeof(Math);
var result = concreteType.GetMethod("Sin").Invoke(null, new object[] { numbers });
Upvotes: 2