获得实例的类型 string str = "abc";object ob=str;如何可以获得ob的真正类型名system.string呢? 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 MessageBox.Show("ss".GetType().FullName); byte a = 1; char b = 'a'; short c = 1; this.textBox1.Text = ""; this.textBox1.AppendText("byte -> " + a.GetType().FullName + "\n"); this.textBox1.AppendText("char -> " + b.GetType().FullName + "\n"); this.textBox1.AppendText("short -> " + c.GetType().FullName + "\n");结果:byte -> System.Bytechar -> System.Charshort -> System.Int16 Type type = obj.GetType();Console.WriteLine("类型名:" + type.Name);Console.WriteLine("类全名:"+type.FullName); 我错了,ob.GetType().FullName是可以的 经过 验证 用 GetType() 方法仍然可以显示出来 类型 c#越来越优雅 或 ava越来越难用 100分请人帮我组织一句JavaScript vs2005 智能感知 不好用了~~~急....!!!! 关于VS2005连接SQL2000问题 windows服务中能否调用API函数 求arcgis 9.3 server adf for .net 请教个C#开发个声学测试软件的思路 异步BeginInvoke的问题 问一下关于Listview 图片相关问题 转换string数组元素 数据集之间可以相互赋值 Visual C# 2005+SQL Server 2005数据库开发与实例
this.textBox1.Text = "";
this.textBox1.AppendText("byte -> " + a.GetType().FullName + "\n");
this.textBox1.AppendText("char -> " + b.GetType().FullName + "\n");
this.textBox1.AppendText("short -> " + c.GetType().FullName + "\n");
结果:
byte -> System.Byte
char -> System.Char
short -> System.Int16
Console.WriteLine("类型名:" + type.Name);
Console.WriteLine("类全名:"+type.FullName);
ob.GetType().FullName
是可以的