The other answers have shown how you can (and should, IMO) do this without LINQ – but they’ve both still got the same problem that your original code does: you’re only checking whether the data set has any tables – it could have fewer than tableNo
tables. I would suggest:
public bool IsNullOrEmptyDataTable(DataSet objDataset, int tableNo)
{
return objDataset == null ||
objDataset.Table.Count <= tableNo ||
objDataset.Tables[tableNo].Rows.Count == 0;
}
1
solved How to convert this code to LINQ [closed]