我查看了我的代码,并且我特别确保使用Rows.Count
(supportPointSelected
)不会发生这种情况。我检查Count,如果且仅仅是大于0(代码的第一个IF
语句)我继续它。请在下面找到代码。
private List<byte> routeHandler(DataTable supportPointSelected, double taskState, int indices)
{
//TPCANStatus statusCan = new TPCANStatus();
int a = supportPointSelected.Columns.IndexOf("Number"); // column number indices
int b = supportPointSelected.Columns.IndexOf("XSupport"); // column number X
int c = supportPointSelected.Columns.IndexOf("YSupport"); // column number Y
int d = supportPointSelected.Columns.IndexOf("VSupport"); // column number Velocity
if (supportPointSelected.Rows.Count > 0) // Check to Avoid the Error
{
if (Convert.ToDouble(supportPointSelected.Rows[0][d]) == 0)
{
supportPointSelected.Rows[0][d] = 0.01; // This is the Point the Error Occurs
}
else { }
}
else { }
List<byte> output = new List<byte>();
// Logic do Something
return output;
}