[C#] C# (Csharp) 中的GetType 方法使用范例 →→→→→进入此内容的聊天室

来自 , 2020-08-11, 写在 C#, 查看 142 次.
URL http://www.code666.cn/view/bc9c8c70
  1. using System;
  2.  
  3. class TypeClass
  4. {
  5. static void Main(string [] args)
  6. {
  7. //create object of type object and string
  8. Object cls1 = new Object ();
  9. System.String cls2 = "Test string";
  10.  
  11. // Call Get Type to return the type
  12. Type type1 = cls1.GetType( );
  13. Type type2 =cls2.GetType( );
  14.  
  15. // Object class output
  16. Console.WriteLine(type1.BaseType);
  17. Console.WriteLine(type1.Name);
  18. Console.WriteLine(type1.FullName);
  19. Console.WriteLine(type1.Namespace);
  20.  
  21. // String output
  22. Console.WriteLine(type2.BaseType);
  23. Console.WriteLine(type2.Name);
  24. Console.WriteLine(type2.FullName);
  25. Console.WriteLine(type2.Namespace);
  26. }
  27. }
  28. //csharp/7498

回复 "C# (Csharp) 中的GetType 方法使用范例"

这儿你可以回复上面这条便签

captcha