Assembly.GetExecutingAssembly()

作者:追风剑情 发布于:2018-1-15 18:05 分类:C#

示例

  1. using UnityEngine;
  2. using System;
  3. using System.Linq;
  4. using System.Reflection;
  5. using System.Collections;
  6. using System.Collections.Generic;
  7.  
  8. namespace my_test {
  9. public class Test1 : MonoBehaviour {
  10.  
  11. void Start()
  12. {
  13. PrintExecutingAssembly();
  14. }
  15.  
  16. private void PrintExecutingAssembly()
  17. {
  18. //得到当前执行代码所在程序集中命名空间为my_test中的类型定义
  19. List<Type> types = (from type in Assembly.GetExecutingAssembly().GetTypes()
  20. where type.Namespace == "my_test"
  21. select type).ToList();
  22. for (int i = 0; i < types.Count; i++)
  23. Debug.Log(types[i].FullName);
  24. }
  25. }
  26.  
  27. public class Test2
  28. {
  29. private class Test2_2 { }
  30. }
  31.  
  32. public struct Struct1 { }
  33.  
  34. public enum Enum1 { }
  35. }

运行测试

11111.png

标签: C#

Powered by emlog  蜀ICP备18021003号-1   sitemap

川公网安备 51019002001593号