convert a string into an executable code

Hello I wont to convert a string into an executable line of code.

For example string str = “methodname(intI, stringS);” ;

Is there any way to do that in c#

I don’t know how many functions you need to do this for (or why, still), but you could try assigning a dummy struct as your function parameter.

Instead of:

private void methodname (int I, string S)
{
	Debug.Log (I + " " + S);
}

You could do:

public struct MethodParams
{
	// Parameters here
	public int I;
	public string S;

	// Single Object contains them both
	public MethodParams (int i, string s)
	{
		I = i;
		S = s;
	}
}

And then pass this in by adjusting your function

private void methodname (MethodParams mp)
{
	Debug.Log (mp.I + " " + mp.S);
}