我有一组带有字符串、整型和布尔型参数的C#函数,它们用作数据输入接口。我希望能够为每个方法创建一个webform;为每个string/int创建一个文本框,为每个bool创建一个复选框。
有没有办法让这个过程自动化呢?
发布于 2010-09-24 14:59:29
您需要使用反射来检索方法的签名,然后根据其参数创建一个web表单
// Create a container (panel for instance)
var parameters = methodInfo.GetParameters();
foreach (var parameter in parameters)
{
if (parameter.ParameterType == typeof(string))
{//Create a text box and add it to the panel}
else if (parameter.ParameterType == typeof(int))
{//Create a numeric box and add it to the panel}
...
}https://stackoverflow.com/questions/3784175
复制相似问题