我不能將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