首页 新闻 会员 周边

一个不解的问题

0
[已解决问题] 解决于 2009-11-12 09:07

public class test
{
}

public class test3<T>

{

        public string saytype<T>(test3<T> o)
        {
            return o.GetType().ToString();
        }

}

在主函数中这样写:

test3<test> aa = new test3<test>();

Console.WriteLine(aa.saytype(aa));

输入的是:test.test3`1[test.test]

提问:其中输出的`1是什么意思?

Solution的主页 Solution | 初学一级 | 园豆:200
提问于:2009-11-10 14:59
< >
分享
最佳答案
0

根据msdn的资料,"`1"中"`"表示的是泛型类型,"1"表示泛型类型的参数的个数是1.

请参考http://msdn.microsoft.com/zh-cn/library/w3f99sx1(VS.95).aspx

莫慌 | 初学一级 |园豆:9 | 2009-11-10 20:25
其他回答(3)
0

Type t= o.GetType();

return t.Name;

一滴血 | 园豆:1602 (小虾三级) | 2009-11-10 17:35
0

范型。

| 园豆:27 (初学一级) | 2009-11-10 23:41
0

gettype()是获取到类的原型。你这样获取的就是一个test下的test原型!

Peter Yao | 园豆:225 (菜鸟二级) | 2009-11-11 18:57
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册