阅读984 返回首页    go 阿里云 go 技术社区[云栖]


C#typeof

private Type GetInputType()
        {
            string strText = txtType.Text;
            switch (strText)
            {
                case "Int32": case "int" : case "System.Int32":
                    return typeof(int);
                case "Double": case "double": case "System.Double":
                    return typeof(double);
                case "float": case "Float": case "System.Float":
                    return typeof(float);
                case "Int16": case "System.Int16": case "short":
                    return typeof(short);
                case "Decimal": case "decimal": case "System.Decimal":
                    return typeof(decimal);
                default:
                    return typeof(int); 
            }
            
        }

        private void btnCapture_Click(object sender, EventArgs e)
        {
            Type type = GetInputType();
            string strTemp = null;

            foreach (MethodInfo method in type.GetMethods())
            {
                strTemp = "方法:" + method.Name + "\n";
                rtxtCapture.AppendText(strTemp);
                foreach (ParameterInfo parameter in method.GetParameters())
                {
                    strTemp = "参数: " + parameter.Name + "\n";
                    rtxtCapture.AppendText(strTemp);
                }
                rtxtCapture.AppendText(Environment.NewLine);                   //添加换行
            }
        }


 

最后更新:2017-04-02 00:06:49

  上一篇:go POJ 1745DP
  下一篇:go 比较全面的gdb调试命令