我在这一行收到错误
“array [i,j] =((DateTime)array [i,j])。ToString(”dd-MMM-yyyy“);”
错误消息:无法将类型'TOutput'转换为'System.DateTime'
请帮帮我。
var ObjJagArr = Dt.AsEnumerable()
.Select(row => row.ItemArray).ToArray();
object[,] MultiArr = ConvertAll(ObjJagArr, x => x);
public static TOutput[,] ConvertAll<TInput, TOutput>(
this TInput[][] Jarr, Func<TInput, TOutput> converter)
{
int rows = Jarr.Length;
int cols = Jarr.Max(subArray => subArray.Length);
TOutput[,] array = new TOutput[rows, cols];
for (int i = 0; i < rows; i++)
{
for (int j = 0; j < cols; j++)
{
array[i, j] = converter(Jarr[i][j]);
if (array[i, j].GetType().Name.Equals("DateTime"))
{
//array[i, j] = ((DateTime)array[i, j]).ToString("dd-MMM-yyyy");
string strDt = Convert.ToDateTime(array[i, j]).ToShortDateString();
array[i, j] = (TOutput)(object)strDt;
}
}
}
return array;
}
解决了这个问题。 我忘记了拳击的问题