1
using System;
2
using System.Collections.Generic;
3
using System.Text;
4
5
namespace GenericTest
6

{
7
class GenericClass
8
{
9
//申明一个泛型方法
10
public T getvalue<T>(T t)
11
{
12
return t;
13
}
14
15
//调用泛型方法
16
//注意:在调用泛型方法时,对泛型方法的类型参数实例化
17
public int useMethod()
18
{
19
return this.getvalue<int>(10);
20
}
21
22
//重载getvalue方法
23
public int getvalue(int i)
24
{
25
return i;
26
}
27
}
using System;2
using System.Collections.Generic;3
using System.Text;4

5
namespace GenericTest6


{7
class GenericClass8

{9
//申明一个泛型方法10
public T getvalue<T>(T t)11

{12
return t;13
}14

15
//调用泛型方法16
//注意:在调用泛型方法时,对泛型方法的类型参数实例化17
public int useMethod()18

{19
return this.getvalue<int>(10);20
}21

22
//重载getvalue方法23
public int getvalue(int i)24

{25
return i;26
}27
}
674

被折叠的 条评论
为什么被折叠?



