turn string into function with arguments?

Is there a way besides eval to turn a string into a function with arguments, either in C#
or javascript.

I want a string like this “somefunction(1,2)” to be somehow turned into the real function.

I use unityscript but if c# has a solution I could use that. I just don’t know how to combine a c# function with a unityscript function.

Thanks,

I believe SendMessage is more or less what you’re looking for: Unity - Scripting API: GameObject.SendMessage

Otherwise maybe Invoke:

If your string is in the format “somefunction(1,2)” then you’ll need to parse the arguments in order to pass them to SendMessage. I’m not familiar with the string library in Unityscript, but you basically grab the substring between ‘(’ and ‘)’ then split on ‘,’ and place it into a generic data structure so you can pass it as a parameter in SendMessage. Somebody may be able to help you with that.

Invoke doesn’t allow you to pass arguments.