C#范型实例运用1
发布:admin | 发布时间: 2008年10月16日using System;
using System.Collections.Generic;
using System.Text;
namespace jiaohuan
{
public class jiaohuan
{
T temp = default(T);
//交换数据
public void prinf(T[] list, int i, int j)
{
this.temp = list[i];
list[i] = list[j];
list[j] = temp;
}
//输出数据
public void printf(T[] list)
{
foreach (T infor in list)
{
Console.WriteLine(infor);
}
Console.WriteLine();
}
}
class Program
{
static void Main(string[] args)
{
jiaohuan
int[] a = new int[10];
for (int i = 0; i < a.Length; i++)
{
a[i] = i + 1;
}
Console.WriteLine("-----交换前------");
jh.printf(a);
Console.WriteLine("-----交换后------");
jh.prinf(a,9,0);
jh.printf(a);
}
}
}
发布:admin | 分类:asp.net | 评论:0 | 引用:0 | 浏览:
| TrackBack引用地址
- 相关文章:
发表评论
◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。






