Dynamically call a definition using a string

I’ve been staring at this for a couple of days now, I know that System.Reflection can dynamically call a method from a string but I cant find a way to get anything to do it dynamically for a definition to return a value

                var resourceRequired = "resource" + resourceNumber + "Amount"; 

                if (spacePeon.maximumCarryAmount > assignedSite.GetComponent<Buildingconstruction>().resourceRequired)
                {
                    pickupamount = assignedsite.GetComponent<Buildingconstruction>().resourcerequired;
                }

resourceRequired should return an int value but I cannot for the life of me work out how to do this

To invoke a function via reflection, you’ll need to get a MethodInfo object.

You can do this with:

string myMethodName = "methodInMyType";
Type myType = typeof (MyType);
MethodInfo method = myType.GetMethod (myMethodName);

var result = method.Invoke (MyTypeObject, null);