zoukankan      html  css  js  c++  java
  • c# 反射获取一个类型取到null

    经常用 GetType 获取一个Type

    1. 想获取的 Type 在当前执行的 assembly 里面,则可以直接获取

    Type myType1 = Type.GetType("System.Int32");

    2. 想获取的 Type 不在当前的assembly 里面,直接获取得到 null

    Type t = Type.GetType("System.Runtime.InteropServices.RuntimeInformation");
    // t == null

    必须用 AssemblyQualifiedName 去获取

    Type t = Type.GetType("System.Runtime.InteropServices.RuntimeInformation, System.Runtime.InteropServices.RuntimeInformation, Version=4.0.4.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a");
  • 相关阅读:
    TCP之Nagle算法与TCP_NODELAY
    CSPS模拟 87
    CSPS模拟 86
    CSPS模拟 85
    CSPS模拟 84
    CSPS模拟 83
    CSPS模拟 82
    CSPS模拟 81
    CSPS模拟 80
    CSPS模拟 79
  • 原文地址:https://www.cnblogs.com/chenyingzuo/p/12366016.html
Copyright © 2011-2022 走看看