using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Reflection;namespace 使用typeof关键字获取类的内部结构
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
} private void button1_Click(object sender, EventArgs e)
{
Type type = typeof(System.Int32);
foreach (MethodInfo method in type.GetMethod())
{
richTextBox1.AppendText("方法名称:" + method.Name + Environment.NewLine);
foreach (ParameterInfo parameter in method.GetParameters())
{
richTextBox1.AppendText("参数:" + parameter.Name + Environment.NewLine);
}
}
}
}
}
错误提示是:“GetMethod”方法没有采用“0”个参数的重载
这个该怎么解决。。望哪位高手给出详细解答
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Reflection;namespace 使用typeof关键字获取类的内部结构
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
} private void button1_Click(object sender, EventArgs e)
{
Type type = typeof(System.Int32);
foreach (MethodInfo method in type.GetMethod())
{
richTextBox1.AppendText("方法名称:" + method.Name + Environment.NewLine);
foreach (ParameterInfo parameter in method.GetParameters())
{
richTextBox1.AppendText("参数:" + parameter.Name + Environment.NewLine);
}
}
}
}
}
错误提示是:“GetMethod”方法没有采用“0”个参数的重载
这个该怎么解决。。望哪位高手给出详细解答
不是 type.GetMethod() 只是一个
GetMethod需要参数。比如方法名字符串。
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Runtime.InteropServices;
using System.Reflection;namespace WindowsFormsApplication2
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
}
private void button1_Click(object sender, EventArgs e)
{
Type type = typeof(System.Int32);
foreach (MethodInfo method in type.GetMethods())
{
richTextBox1.AppendText("方法名称:" + method.Name + Environment.NewLine);
foreach (ParameterInfo parameter in method.GetParameters())
{
richTextBox1.AppendText("参数:" + parameter.Name + Environment.NewLine);
}
}
}
}
}
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Runtime.InteropServices;
using System.Reflection;namespace WindowsFormsApplication2
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
}
private void button1_Click(object sender, EventArgs e)
{
Type type = typeof(System.Int32);
foreach (MethodInfo method in type.GetMethods())
{
richTextBox1.AppendText("方法名称:" + method.Name + Environment.NewLine);
foreach (ParameterInfo parameter in method.GetParameters())
{
richTextBox1.AppendText("参数:" + parameter.Name + Environment.NewLine);
}
}
}
}
}