zoukankan      html  css  js  c++  java
  • Part 53 to 55 Talking about Reflection in C#

    Part 53 Reflection in C#

    Part 54 Reflection Example

    here is the code

    复制代码
    private void btnDiscover_Click(object sender, EventArgs e)
    {
        lbMethods.Items.Clear();
        lbProperties.Items.Clear();
        lbConstructor.Items.Clear();
        string typeName = txtTypeName.Text.Trim();
        Type t = Type.GetType(typeName);
        if (t == null)
        {
            MessageBox.Show("Type Is No Exit, Please Enter A Right Type!", "Warnning", MessageBoxButtons.OK);
            txtTypeName.Clear();
            txtTypeName.Focus();
        }
        else
        {
            MethodInfo[] methods = t.GetMethods();
            PropertyInfo[] properties = t.GetProperties();
            ConstructorInfo[] constructors = t.GetConstructors();
            foreach (var method in methods)
            {
                lbMethods.Items.Add(string.Concat(method.ReturnType.Name," ", method.Name));
            }
            foreach (var property in properties)
            {
              lbProperties.Items.Add(string.Concat(property.PropertyType.Name, " ", property.Name));
            }
            foreach (var constructor in constructors)
            {
              lbConstructor.Items.Add(constructor.ToString());
            }
        }
    }            
    复制代码

    Part 55 Late binding using reflection

  • 相关阅读:
    leetcode69
    leetcode204
    leetcode414
    leetcode532
    leetcode28
    leetcode155
    leetcode303
    leetcode190
    2018-7-21-win10-uwp-调用-Microsoft.Windows.Photos_8wekyb3d8bbwe-应用
    2018-7-21-win10-uwp-调用-Microsoft.Windows.Photos_8wekyb3d8bbwe-应用
  • 原文地址:https://www.cnblogs.com/gester/p/4870568.html
Copyright © 2011-2022 走看看