匿名型のプロパティが関数のパラメーターである場合、関数内に匿名型を作成したいと考えています。
たとえば、関数の場合: private bool CreatePerson(string FirstName, string LasName, int Age, int height);
FirstName、LasName、Age、および height のプロパティを持つ匿名型があります。関数パラメーターの値は、匿名型のプロパティの値になります。
private bool CreatePerson(string FirstName, string LasName, int Age, int height)
{
// Get this method parameters
MethodBase currentMethod = MethodBase.GetCurrentMethod();
ParameterInfo[] parametersInfo = currentMethod.GetParameters();
// create an object of the parameters from the function.
foreach (ParameterInfo paramInfo in parametersInfo)
{
// add a property with the name of the parameter to an anonymous object and insert its value to the property.
// WHAT DO I DO HERE?
....
}
return true;
}