C# 反射的知识点实验程序

勇哥之前学习反射时的测试代码,希望对各位有点参考意义。


image.png


程序工程结构如下:

image.png

参考代码:

lib1.class1.cs

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace lib1
{
    public class Class1
    {
        public enum people
        {
            blue8,hackpig,hao123,homemy
        }

        private string _name;

        public string Name
        {
            get { return _name; }
            set { _name = value; }
        }

        private int _age;

        public int Age
        {
            get { return _age; }
            set { _age = value; }
        }


        public Class1()
        {
            _age = 18;
            Name = "刘小勇";
        }

        public int test1(int a, int b)
        {
            return a + b;
        }

        public string test2(string s1, string s2)
        {
            return s1 + "," + s2;
        }
    }
}

reflectTest.class1.cs

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace reflectTest
{
    class Class1
    {
        public static string StaticPer = "StaticPer...";
        public readonly string ReadOnlyPer = "ReadOnlyPer..";
        public const string ConstPer = "ConstPer..";
 
        public string GetPer { get { return "GetPer..."; } }
        private string _SetPer;
        public string SetPer { set { _SetPer = value; } }
        public string GetSetPer { get; set; }

        public Class1()
        {
        }

        public string test1(int param)
        {
            return "刘小勇"+param;
        }

        private int test2()
        {
            return 888;
        }

    }
}

reflectTest.class2.cs

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Reflection;
using Microsoft.CSharp;
using System.CodeDom.Compiler;

namespace reflectTest
{
    class Class2
    {
        public static Assembly NewAssembly()
        {
            //创建编译器实例。 
            var provider = new CSharpCodeProvider();
            //设置编译参数。 
            var cp = new CompilerParameters();
            cp.GenerateExecutable = false;
            cp.GenerateInMemory = true;
            // Generate an executable instead of
            // a class library.
            //cp.GenerateExecutable = true;
            // Set the assembly file name to generate.
            cp.OutputAssembly = "c:\\1.dll";
            // Generate debug information.
            cp.IncludeDebugInformation = true;
            // Save the assembly as a physical file.
            cp.GenerateInMemory = false;
            // Set the level at which the compiler
            // should start displaying warnings.
            cp.WarningLevel = 3;
            // Set whether to treat all warnings as errors.
            cp.TreatWarningsAsErrors = false;
            // Set compiler argument to optimize output.
            cp.CompilerOptions = "/optimize";
            cp.ReferencedAssemblies.Add("System.dll");
            //cp.ReferencedAssemblies.Add("System.Core.dll");
            cp.ReferencedAssemblies.Add("System.Data.dll");
            //cp.ReferencedAssemblies.Add("System.Data.DataSetExtensions.dll");
            cp.ReferencedAssemblies.Add("System.Deployment.dll");
            cp.ReferencedAssemblies.Add("System.Design.dll");
            cp.ReferencedAssemblies.Add("System.Drawing.dll");
            cp.ReferencedAssemblies.Add("System.Windows.Forms.dll");
            //创建动态代码。 
            StringBuilder classSource = new StringBuilder();
            classSource.Append("using System;using System.Windows.Forms;\npublic  class  DynamicClass: UserControl \n");
            classSource.Append("{\n");
            classSource.Append("public DynamicClass()\n{\nInitializeComponent();\nConsole.WriteLine(\"hello\");}\n");
            classSource.Append("private System.ComponentModel.IContainer components = null;\nprotected override void Dispose(bool disposing)\n{\n");
            classSource.Append("if (disposing && (components != null)){components.Dispose();}base.Dispose(disposing);\n}\n");
            classSource.Append("private void InitializeComponent(){\nthis.SuspendLayout();this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);");
            classSource.Append("this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;this.Name = \"DynamicClass\";this.Size = new System.Drawing.Size(112, 74);this.ResumeLayout(false);\n}");
            //创建属性。 
            /*************************在这里改成需要的属性******************************/
            classSource.Append(propertyString("aaa"));
            classSource.Append(propertyString("bbb"));
            classSource.Append(propertyString("ccc"));
            classSource.Append("}");
            System.Diagnostics.Debug.WriteLine(classSource.ToString());
            //编译代码。 
            CompilerResults result = provider.CompileAssemblyFromSource(cp, classSource.ToString());
            if (result.Errors.Count > 0)
            {
                for (int i = 0; i < result.Errors.Count; i++)
                    Console.WriteLine(result.Errors[i]);
                Console.WriteLine("error");
                return null;
            }
            //获取编译后的程序集。 
            Assembly assembly = result.CompiledAssembly;
            return assembly;
        }
        private static string propertyString(string propertyName)
        {
            StringBuilder sbProperty = new StringBuilder();
            sbProperty.Append(" private  int  _" + propertyName + "  =  0;\n");
            sbProperty.Append(" public  int  " + "" + propertyName + "\n");
            sbProperty.Append(" {\n");
            sbProperty.Append(" get{  return  _" + propertyName + ";}  \n");
            sbProperty.Append(" set{  _" + propertyName + "  =  value;  }\n");
            sbProperty.Append(" }");
            return sbProperty.ToString();
        }
    }
}


reflectTest.class3.cs

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Net;
using System.IO;
using System.CodeDom;
using System.CodeDom.Compiler;
using Microsoft.CSharp;

namespace reflectTest
{
    class Class3
    {
        public static object InvokeWebService(string url, string methodname, object[] args)
        {
            return InvokeWebService(url, null, methodname, args);
        }

        public static object InvokeWebService(string url, string classname, string methodname, object[] args)
        {
            string @namespace = "EnterpriseServerBase.WebService.DynamicWebCalling";
            if ((classname == null) || (classname == ""))
            {
                classname = GetWsClassName(url);
            }

            try
            {
                //获取WSDL
                WebClient wc = new WebClient();
                Stream stream = wc.OpenRead(url + "?WSDL");
                //ServiceDescription sd = ServiceDescription.Read(stream);
                //ServiceDescriptionImporter sdi = new ServiceDescriptionImporter();
                //sdi.AddServiceDescription(sd, "", "");
                CodeNamespace cn = new CodeNamespace(@namespace);

                //生成客户端代理类代码
                CodeCompileUnit ccu = new CodeCompileUnit();
                ccu.Namespaces.Add(cn);
                //sdi.Import(cn, ccu);
                CSharpCodeProvider csc = new CSharpCodeProvider();
                ICodeCompiler icc = csc.CreateCompiler();

                //设定编译参数
                CompilerParameters cplist = new CompilerParameters();
                cplist.GenerateExecutable = false;
                cplist.GenerateInMemory = true;
                cplist.ReferencedAssemblies.Add("System.dll");
                cplist.ReferencedAssemblies.Add("System.XML.dll");
                cplist.ReferencedAssemblies.Add("System.Web.Services.dll");
                cplist.ReferencedAssemblies.Add("System.Data.dll");

                //编译代理类
                CompilerResults cr = icc.CompileAssemblyFromDom(cplist, ccu);
                if (true == cr.Errors.HasErrors)
                {
                    System.Text.StringBuilder sb = new System.Text.StringBuilder();
                    foreach (System.CodeDom.Compiler.CompilerError ce in cr.Errors)
                    {
                        sb.Append(ce.ToString());
                        sb.Append(System.Environment.NewLine);
                    }
                    throw new Exception(sb.ToString());
                }

                //生成代理实例,并调用方法
                System.Reflection.Assembly assembly = cr.CompiledAssembly;
                Type t = assembly.GetType(@namespace + "." + classname, true, true);
                object obj = Activator.CreateInstance(t);
                System.Reflection.MethodInfo mi = t.GetMethod(methodname);

                return mi.Invoke(obj, args);
            }
            catch (Exception ex)
            {
                throw new Exception(ex.InnerException.Message, new Exception(ex.InnerException.StackTrace));
            }
        }

        private static string GetWsClassName(string wsUrl)
        {
            string[] parts = wsUrl.Split('/');
            string[] pps = parts[parts.Length - 1].Split('.');
            return pps[0];
        }
    }
}

reflectTest.class4.cs

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace reflectTest
{
    /// <summary>
    /// 数据库字段的用途。
    /// </summary>
    public enum EnumDBFieldUsage
    {
        /// <summary>
        /// 未定义。
        /// </summary>
        None = 0x00,
        /// <summary>
        /// 用于主键。
        /// </summary>
        PrimaryKey = 0x01,
        /// <summary>
        /// 用于唯一键。
        /// </summary>
        UniqueKey = 0x02,
        /// <summary>
        /// 由系统控制该字段的值。
        /// </summary>
        BySystem = 0x04
    }

    [AttributeUsage(AttributeTargets.Property, Inherited = true)]
    public class DBFieldAttribute : Attribute
    {
        EnumDBFieldUsage m_usage;
        string m_strFieldName;
        string m_strDescription;
        object m_defaultValue;

        public DBFieldAttribute(string strFieldName, object defaultValue, EnumDBFieldUsage usage, string strDescription)
        {
            m_strFieldName = strFieldName;
            m_defaultValue = defaultValue;
            m_usage = usage;
            m_strDescription = strDescription;
        }

        public DBFieldAttribute(string fieldName)
            : this(fieldName, null, EnumDBFieldUsage.None, null)
        { }

        public DBFieldAttribute(string fieldName, EnumDBFieldUsage usage)
            : this(fieldName, null, usage, null)
        { }


        // 获取该成员映射的数据库字段名称。
        public string FieldName
        {
            get
            {
                return m_strFieldName;
            }
            set
            {
                m_strFieldName = value;
            }
        }

        // 获取该字段的默认值
        public object DefaultValue
        {
            get
            {
                return m_defaultValue;
            }
            set
            {
                m_defaultValue = value;
            }
        }
    }
}

reflectTest.class5.cs

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace reflectTest
{
    class DalObj
    {
        string m_strTableName;
        int m_nID;
        string m_strName;
        string m_password;

        public DalObj(string strTableName)
        {
            m_strTableName = strTableName;
        }

        [DBField("id", EnumDBFieldUsage.PrimaryKey)]
        public int ID
        {
            get { return m_nID; }
            set { m_nID = value; }
        }

        [DBField("name", DefaultValue = "游客")]
        public string Name
        {
            get { return m_strName; }
            set { m_strName = value; }
        }

        [DBField("pwd")]
        public string PassWord
        {
            get { return m_password; }
            set { m_password = value; }
        }
    }
}

reflectTest.class6.cs

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Reflection;
using System.Windows.Forms;

namespace reflectClass6
{
    class TestClass
    {
        public delegate string TestDelegate();
        public void TestMethod(TestDelegate foo)
        {
            //Console.WriteLine(foo());
            MessageBox.Show(foo());
        }
    }

    class Program1
    {
        public static string GetText() { return "Hello World!"; }

        public static void MainFun()
        {
            //string assemblyname = Assembly.Load("reflectTest").FullName ;  //reflectTest
            //assemblyname = Assembly.GetAssembly(typeof(Program1)).FullName;  //reflectTest

            object obj = Activator.CreateInstance(Assembly.GetAssembly(typeof(Program1)).FullName, "reflectClass6.TestClass").Unwrap();
            Type del = obj.GetType().GetNestedType("TestDelegate");
            var method = obj.GetType().GetMethod("TestMethod");
            Delegate d = Delegate.CreateDelegate(del, typeof(Program1).GetMethod("GetText"));
            method.Invoke(obj, new object[] { d });
        }
    }
}

reflectTest.Form1.cs

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;
using System.Diagnostics;

namespace reflectTest
{
    public partial class Form1 : Form
    {
        enum enum1
        {
            a1, a2, a3
        }

        public Form1()
        {
            InitializeComponent();
        }

        private void btnTest1_Click(object sender, EventArgs e)
        {
            //按钮“遍历类的成员”
            var obj = new Class1();
            var type = obj.GetType();
            var p = type.GetProperties(BindingFlags.Instance | BindingFlags.Public );

            StringBuilder sb1 = new StringBuilder();

            MemberInfo[] members = type.GetMembers();
            foreach (MemberInfo m in members)
            {
                switch (m.MemberType)
                {
                    case MemberTypes.Constructor:
                        sb1.Append(string.Format("构造函数:{0}\n",m.Name));
                        break;
                    case MemberTypes.Field:
                        sb1.Append(string.Format("字段:{0}\n", m.Name));
                        break;
                    case MemberTypes.Method:
                        sb1.Append(string.Format("方法:{0}\n", m.Name));
                        break;
                    case MemberTypes.Property:
                        sb1.Append(string.Format("属性:{0}\n", m.Name));
                        break;
                }
            }

            foreach (var item in p)
            {
                sb1.Append(string.Format("Name: {0}\n", item.Name));
            }

            foreach (FieldInfo field in type.GetFields())
            {
               sb1.Append(string.Format("Field: {0}, Value:{1}\n", field.Name, field.GetValue(obj)));
            }

            MethodInfo[] methods = type.GetMethods();
            foreach (MethodInfo m in methods)
            {
                sb1.Append(string.Format("方法名:{0}\n",m.Name));
            }

            this.rtbMsg.AppendText(sb1.ToString());

            //由属性名取其值
            var value = type.GetFields().FirstOrDefault(f => f.Name == "StaticPer").GetValue(obj);
            this.rtbMsg.AppendText(value.ToString()+"\n");

            //调用成员方法
            foreach (MethodInfo m in methods)
            {
                if (m.Name.Equals("test1"))
                {
                    object[] ob=new object[]{888};
                    this.rtbMsg.AppendText(string.Format("test()={0}", 
                        m.Invoke(
                        obj, 
                        ob)
                        ));
                    break;
                }
            }

        }

        private void btnTest2_Click(object sender, EventArgs e)
        {
            //按钮“动态创建类”
            Assembly a1 = Class2.NewAssembly();
        }

        private void btnTest3_Click(object sender, EventArgs e)
        {
            //按钮“Type类”
            string[] s1 = new string[] { "a","b","c"};

            double d1 = 10;
            Type t1 = d1.GetType();

            Type t2 = Type.GetType("System.Double");



            Type t3=typeof(Class1);
            Assembly assem = t3.Assembly;


            StringBuilder sb1=new StringBuilder();
            sb1.Append(string.Format(@"
数据类型名:{0}
数据类型完全限定名(包括名称空间):{1}
在其中定义数据类型的名称空间名:{2} 
该Type的直接基本类型: {3} 
该Type在.net运行库中映射到的类型: {4}
 
t1.IsAbstract={5}
t1.IsClass={6} 
t1.IsEnum={7}
t1.IsInterface={8}
t1.IsValueType={9} 
t1.IsPrimitive={10}
Class1.IsClass={11}
enum1.IsEnum={12}
sender.IsMarshalByRef={13}
Class1.Assembly={14}

",
                t1.Name,t1.FullName,t1.Namespace,t1.BaseType,t1.UnderlyingSystemType,
                t1.IsAbstract,t1.IsClass,t1.IsEnum,t1.IsInterface,t1.IsValueType,t1.IsPrimitive,
                typeof(Class1).IsClass, typeof(enum1).IsEnum, sender.GetType().IsMarshalByRef,
                assem.FullName));
            this.rtbMsg.AppendText(sb1.ToString());

            Type t5 = typeof(double);

            ConstructorInfo[] ci = t5.GetConstructors();
            EventInfo[] ei = t5.GetEvents();
            FieldInfo[] fi = t5.GetFields();
            Type[] im = t5.GetInterfaces();
            MemberInfo[] mi = t5.GetMembers();
            MethodInfo[] mei = t5.GetMethods();
            PropertyInfo[] pi = t5.GetProperties();
            Debug.Assert(false);
        }

        private void btnTest4_Click(object sender, EventArgs e)
        {
            //按钮“Assembly类”
            StringBuilder sb1 = new StringBuilder();
            Assembly assem = Assembly.LoadFile(Environment.CurrentDirectory + "\\lib1.dll");
            Type[] t1 = assem.GetTypes();
            foreach (Type m in t1)
            {
                MemberInfo[] mi = m.GetMembers();
                foreach (MemberInfo m1 in mi)
                {
                    sb1.Append(string.Format("Type m: {0},{1},{2}   \nMemberInfo: Name={3},Module={4},MemberType={5}\n", 
                      m.Name, m.Module, m.MemberType,  m1.Name, m1.Module, m1.MemberType));
                }
            }
            this.rtbMsg.AppendText(sb1.ToString());
        }

        private void btnTest5_Click(object sender, EventArgs e)
        {
            //按钮“自定义属性”
            DalObj dalObj = new DalObj("users");
            StringBuilder sb = new StringBuilder();
            foreach (PropertyInfo proInfo in dalObj.GetType().GetProperties())
            {
                object[] attrs = proInfo.GetCustomAttributes(typeof(DBFieldAttribute), true);
                if (attrs.Length == 1)
                {
                    DBFieldAttribute attr = (DBFieldAttribute)attrs[0];
                    sb.Append(attr.FieldName + ":" + (attr.DefaultValue == null ? "null" : attr.DefaultValue.ToString()) + "\r\n");
                }
            }
            MessageBox.Show(sb.ToString());
        }

        private void btnTest6_Click(object sender, EventArgs e)
        {
            //按钮“调用delegate”
            reflectClass6.Program1.MainFun();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            //铵钮“GetValue()”
            string test = "abcdefghijklmnopqrstuvwxyz";
            // Get a PropertyInfo object representing the Chars property.
            PropertyInfo pinfo = typeof(string).GetProperty("Chars");

            // Show the first, seventh, and last letters
            ShowIndividualCharacters(pinfo, test, 0, 6, test.Length - 1);

            // Show the complete string.
            Console.Write("The entire string: \n");
            for (int x = 0; x < test.Length; x++)
            {
                rtbMsg.AppendText(pinfo.GetValue(test, new Object[] { x }).ToString()+"\n");
            }
            Console.WriteLine();
        }

        void ShowIndividualCharacters(PropertyInfo pinfo,
                                        object value,
                                        params int[] indexes)
        {
            foreach (var index in indexes)
            {
                rtbMsg.AppendText(string.Format("Character in position {0,2}: '{1}'\n",
                                  index, pinfo.GetValue(value, new object[] { index })));
            }
        }

        private void button2_Click(object sender, EventArgs e)
        {
            //按钮“SetValue()”
            MyClass tmp_Class = new MyClass();
            tmp_Class.Property1 = 2;
            Type type = tmp_Class.GetType(); //获取类型
            System.Reflection.PropertyInfo propertyInfo = type.GetProperty("Property1"); //获取指定名称的属性
            int value_Old = (int)propertyInfo.GetValue(tmp_Class, null); //获取属性值
            rtbMsg.AppendText(value_Old.ToString()+"\n");
            propertyInfo.SetValue(tmp_Class, 5, null); //给对应属性赋值
            int value_New = (int)propertyInfo.GetValue(tmp_Class, null);
            rtbMsg.AppendText(value_New.ToString()+"\n");
        }

        private void button3_Click(object sender, EventArgs e)
        {
            //按钮“由变量名字符串,为这个变量赋值”
            test1();
        }

        private void test1()
        {
            var words = new string[] { "Name", "123" };
            Type myTypeA = typeof(common_setting);
            object commonSetting = new common_setting();
            string name1 = ((common_setting)commonSetting).Name;

            var myfieldInfo = myTypeA.GetField(words[0]);
            myfieldInfo.SetValue(commonSetting, words[1]);
            string name2 = ((common_setting)commonSetting).Name;
            rtbMsg.AppendText(name2);
        }

    }

    public class MyClass
    {
        public int Property1 { get; set; }
    }

    public struct common_setting
    {
        public string Name;

    }

}


程序在勇哥的电脑上运行结果如下:

 //按钮“Type类”
 ================
数据类型名:Double
数据类型完全限定名(包括名称空间):System.Double
在其中定义数据类型的名称空间名:System 
该Type的直接基本类型: System.ValueType 
该Type在.net运行库中映射到的类型: System.Double
 
t1.IsAbstract=False
t1.IsClass=False 
t1.IsEnum=False
t1.IsInterface=False
t1.IsValueType=True 
t1.IsPrimitive=True
Class1.IsClass=True
enum1.IsEnum=True
sender.IsMarshalByRef=True
Class1.Assembly=reflectTest, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null


 //按钮“Assembly类”
 ================
 Type m: Class1,lib1.dll,TypeInfo   
MemberInfo: Name=get_Name,Module=lib1.dll,MemberType=Method
Type m: Class1,lib1.dll,TypeInfo   
MemberInfo: Name=set_Name,Module=lib1.dll,MemberType=Method
Type m: Class1,lib1.dll,TypeInfo   
MemberInfo: Name=get_Age,Module=lib1.dll,MemberType=Method
Type m: Class1,lib1.dll,TypeInfo   
MemberInfo: Name=set_Age,Module=lib1.dll,MemberType=Method
Type m: Class1,lib1.dll,TypeInfo   
MemberInfo: Name=test1,Module=lib1.dll,MemberType=Method
Type m: Class1,lib1.dll,TypeInfo   
MemberInfo: Name=test2,Module=lib1.dll,MemberType=Method
Type m: Class1,lib1.dll,TypeInfo   
MemberInfo: Name=ToString,Module=CommonLanguageRuntimeLibrary,MemberType=Method
Type m: Class1,lib1.dll,TypeInfo   
MemberInfo: Name=Equals,Module=CommonLanguageRuntimeLibrary,MemberType=Method
Type m: Class1,lib1.dll,TypeInfo   
MemberInfo: Name=GetHashCode,Module=CommonLanguageRuntimeLibrary,MemberType=Method
Type m: Class1,lib1.dll,TypeInfo   
MemberInfo: Name=GetType,Module=CommonLanguageRuntimeLibrary,MemberType=Method
Type m: Class1,lib1.dll,TypeInfo   
MemberInfo: Name=.ctor,Module=lib1.dll,MemberType=Constructor
Type m: Class1,lib1.dll,TypeInfo   
MemberInfo: Name=Name,Module=lib1.dll,MemberType=Property
Type m: Class1,lib1.dll,TypeInfo   
MemberInfo: Name=Age,Module=lib1.dll,MemberType=Property
Type m: Class1,lib1.dll,TypeInfo   
MemberInfo: Name=people,Module=lib1.dll,MemberType=NestedType
Type m: people,lib1.dll,NestedType   
MemberInfo: Name=Equals,Module=CommonLanguageRuntimeLibrary,MemberType=Method
Type m: people,lib1.dll,NestedType   
MemberInfo: Name=GetHashCode,Module=CommonLanguageRuntimeLibrary,MemberType=Method
Type m: people,lib1.dll,NestedType   
MemberInfo: Name=ToString,Module=CommonLanguageRuntimeLibrary,MemberType=Method
Type m: people,lib1.dll,NestedType   
MemberInfo: Name=ToString,Module=CommonLanguageRuntimeLibrary,MemberType=Method
Type m: people,lib1.dll,NestedType   
MemberInfo: Name=CompareTo,Module=CommonLanguageRuntimeLibrary,MemberType=Method
Type m: people,lib1.dll,NestedType   
MemberInfo: Name=ToString,Module=CommonLanguageRuntimeLibrary,MemberType=Method
Type m: people,lib1.dll,NestedType   
MemberInfo: Name=ToString,Module=CommonLanguageRuntimeLibrary,MemberType=Method
Type m: people,lib1.dll,NestedType   
MemberInfo: Name=HasFlag,Module=CommonLanguageRuntimeLibrary,MemberType=Method
Type m: people,lib1.dll,NestedType   
MemberInfo: Name=GetTypeCode,Module=CommonLanguageRuntimeLibrary,MemberType=Method
Type m: people,lib1.dll,NestedType   
MemberInfo: Name=GetType,Module=CommonLanguageRuntimeLibrary,MemberType=Method
Type m: people,lib1.dll,NestedType   
MemberInfo: Name=value__,Module=lib1.dll,MemberType=Field
Type m: people,lib1.dll,NestedType   
MemberInfo: Name=blue8,Module=lib1.dll,MemberType=Field
Type m: people,lib1.dll,NestedType   
MemberInfo: Name=hackpig,Module=lib1.dll,MemberType=Field
Type m: people,lib1.dll,NestedType   
MemberInfo: Name=hao123,Module=lib1.dll,MemberType=Field
Type m: people,lib1.dll,NestedType   
MemberInfo: Name=homemy,Module=lib1.dll,MemberType=Field

 ////铵钮“GetValue()”
 ================
 Character in position  0: 'a'
Character in position  6: 'g'
Character in position 25: 'z'
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
 
  //按钮“SetValue()”
 ================
 2
 5
 
  //按钮“由变量名字符串,为这个变量赋值”
 ================
 123
 
  //按钮“遍历类的成员”
 ================
 方法:get_GetPer
方法:set_SetPer
方法:get_GetSetPer
方法:set_GetSetPer
方法:test1
方法:ToString
方法:Equals
方法:GetHashCode
方法:GetType
构造函数:.ctor
属性:GetPer
属性:SetPer
属性:GetSetPer
字段:ReadOnlyPer
字段:StaticPer
字段:ConstPer
Name: GetPer
Name: SetPer
Name: GetSetPer
Field: ReadOnlyPer, Value:ReadOnlyPer..
Field: StaticPer, Value:StaticPer...
Field: ConstPer, Value:ConstPer..
方法名:get_GetPer
方法名:set_SetPer
方法名:get_GetSetPer
方法名:set_GetSetPer
方法名:test1
方法名:ToString
方法名:Equals
方法名:GetHashCode
方法名:GetType
StaticPer...
test()=刘小勇888

//按钮“自定义属性”

image.png

//按钮“调用delegate”

image.png


--------------------- 

作者:hackpig
来源:www.skcircle.com
版权声明:本文为博主原创文章,转载请附上博文链接!


#转载请注明出处 www.skcircle.com 《少有人走的路》勇哥的工业自动化技术网站。如果需要本贴图片源码等资源,请向勇哥索取。

发表评论:

◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。

会员中心
搜索
«   2021年1月   »
123
45678910
11121314151617
18192021222324
25262728293031
网站分类
标签列表
最新留言
    热门文章 | 热评文章 | 随机文章
文章归档
友情链接
  • 订阅本站的 RSS 2.0 新闻聚合
  • 扫描加本站机器视觉QQ群,验证答案为:halcon勇哥的机器视觉
  • 扫描加站长微信:站长微信:abc496103864
  • 扫描加站长QQ:
  • 扫描赞赏本站:

Powered By Z-BlogPHP 1.6.0 Valyria

Copyright Your skcircle.com Rights Reserved.

鄂ICP备18008319号


站长QQ:496103864 微信:abc496103864