会员
众包
新闻
博问
闪存
赞助商
HarmonyOS
Chat2DB
所有博客
当前博客
我的博客
我的园子
账号设置
会员中心
简洁模式
...
退出登录
注册
登录
.NET 博客
.NET学习
博客园
首页
新随笔
联系
订阅
管理
c#范型体验
using
System;
using
System.Collections.Generic;
using
System.Text;
namespace
ConsoleApplication1
{
class
Program
{
static
void
WriteSomething
<
T
>
(T x, T y)
{
if
(
typeof
(T)
==
typeof
(
int
))
{
Console.WriteLine(x);
}
if
(
typeof
(T)
==
typeof
(
string
))
{
Console.WriteLine(y);
}
}
static
void
Main(
string
[] args)
{
WriteSomething
<
int
>
(
0
,
9
);
WriteSomething
<
string
>
(
"
1
"
,
"
10
"
);
WriteSomething(
0
,
9
);
WriteSomething(
"
0
"
,
"
9
"
);
Console.ReadLine();
}
}
}
Posted on
2006-09-20 07:08
李通通
阅读(
417
) 评论(
1
)
收藏
举报
刷新页面
返回顶部