简体   繁体   English

如何获取C#类中使用的所有系统类型或内置类型

[英]How to get all the system types or built in types used in a C# class

I am trying to list all the system types used in a C# class. 我试图列出在C#类中使用的所有系统类型。 For example, 例如,

class Program
{
    static void Main(string[] args)
    {
        int i = 0;
        Console.WriteLine(i.ToString());
    }
    private void SomeMethod(float parm1, double param2)
    {
        Assembly assembly = Assembly.LoadFrom(@"AssemblyName");
    }
}

Here I want to list, 在这里我要列出,

  1. Int32 32位
  2. Console 安慰
  3. Void 空洞
  4. Assembly 部件
  5. float 浮动
  6. double
  7. string

How to do this? 这个怎么做?

研究如何迭代C#中的内置类型?

typeof(int).Assembly.GetTypes().Where(t => t.IsPrimitive);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM