using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Collections;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
//自定义泛型
ArrayList arraylist = new ArrayList();
arraylist.Add(1);
arraylist.Add(2);
IList<int> list = ToList<int>(arraylist);
foreach (int i in list)
{
Console.WriteLine(i);
}
Console.ReadLine();
}
static IList<T> ToList<T>(ArrayList arraylist)
{
List<T> list = new List<T>();
foreach (T v in arraylist)
{
list.Add(v);
}
return list;
}
}
泛型
最新推荐文章于 2024-11-10 21:20:41 发布