我不能将T TYPE数组转换为Int数组我的代码如下。如何在c#中实现Array.ConvertAll方法
T [] arra = new T [arr.Length];
int [] converted = new int[arr.Length];
T element;
for (int i = 0; i < arr.Length; i++)
{
for (int j = 0; j < arr.Length - 1-i; j++)
{
Type s = (Type)System.Int64;
Type t = arr.GetType();
Converter<T,int> a;
if (t.Equals(s))
{
Array.ConvertAll<T, int>(arr, Converter < T,int> converted);
}
if (arr[j] > arr[j + 1])
{
element = arr[j];
arr[j] = arr[j + 1];
arr[j + 1] = element;
}
}
}
问题是什么?你得到一个例外吗?你是否收到编译错误? – Dennis 2010-10-18 06:06:46
@ Dede我收到“Convert converted”的错误,表示无效的表达式int –
2010-10-18 06:12:53
@Pro_Zeck:因为这不是有效的代码。 – leppie 2010-10-18 06:19:56