Bug in the reflection code?

Hello, there is a method Main, which receives a list and a string, you need based on the value of a string to form the name of the method and call it, best the list and the string. Decided for this task to use reflection, but gives an error in the string VariableNames = Finder.Invoke(this, new object[] { TextFromFile, FromLanguage });
Writes that it is impossible to convert the type object to the ArrayList, I do not understand where my mistake. Thanks in advance.

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using System.Reflection;
namespace VariableFinder
{
 public class Finder : MonoBehaviour
{
 public ArrayList Main(TextFromFile ArrayList, string FromLanguage)
{
 ArrayList VariableNames;
 string MethodName = "Finder" + FromLanguage.ToUpper();
 Finder MethodInfo = this.GetType().GetMethod(MethodName);
 VariableNames = Finder.Invoke(this, new object[] { TextFromFile, FromLanguage });
 return VariableNames;
}



 //Search methods variable names

 FinderPYTHON public ArrayList(ArrayList TextFromFile, string FromLanguage)
{
 ArrayList VariableNames = new ArrayList();
VariableNames.Add("one");
 return VariableNames;
}

}
}
April 7th 20 at 10:47
1 answer
April 7th 20 at 10:49
Solution
The result of calling the method need to lead to the type of the variable VariableNames:
VariableNames = (ArrayList)Finder.Invoke(this, new object[] { TextFromFile, FromLanguage });
Thank you very much, it worked! - Vivian_Thiel43 commented on April 7th 20 at 10:52

Find more questions by tags C#