例如
将 List< int > 转换成 string[] 系统没有提供现成的方法
这里我们写一个扩展方法
public static string[] ToStringArray(this List<int> list)
{
string[] tmp = new string[list.Count];
for(int i=0;i<list.Count;++i)
{
tmp[i] = list[i].ToString();
}
return tmp;
}
这样我们在使用 List< int > 的时候就能直接 点 出来
List< int > _list = new List< int >();
_list.ToStringArray()
可直接使用