So I have a bunch of methods, all of which take in various parameters of different data types, what i'm trying to achieve is a way to call into another method, passing in all the parameters that the current method takes in as well as its values, and in that method i will eventually be doing different types of validation based on the data type of the parameter. The idea being that I will have one validation method that I will be able to call at the beginning of each method, rather than going through each method and validating the parameters one at a time within each method. Below is a rough outline of what i'm trying to achieve, i've looked around and seem to found some uses with Reflection, but it seems passing the parameter types as well as their values is a bit trickier and was wondering if anyone else had come into a similar form of problem.
public void doStuffA(int a, string b, string c, bool d)
{
var params = ?
if (validateInput(params))
{
// do stuff
}
}
public void doStuffB(string x, string y, int z)
{
var params = ?
if (validateInput(params))
{
// do stuff
}
}
public bool validateInput(? params)
{
// do validation
}