Difference between getting cell value using row.Field <T> (col) and based on row / column index
I'm new to C #, I had this script that worked great
foreach(DataColumn col in dataTab.Columns){
foreach(DataRow row in dataTab.Rows){
row.Field<decimal>(col).ToString(CultureInfo.InvariantCulture); }}
I had to use ToString(CultureInfo.InvariantCulture)to read the decimal separator. anyway, when I changed this code, looping over the row / column indices and putting dataTab[rowIndx][colIndx].ToString(CultureInfo.InvariantCulture), I get an error in the ToString method saying:
no overload for method tostring takes 1 argument
1. How can I fix this error?
- Why did he work the first time and not the second, what is the difference between the two methods?
+4
3 answers
№ 2
, , ?
№ 1
?
Convert.ToString Method (Object, IFormatProvider):
Convert.ToString(dataTab[rowIndx][colIndx], CultureInfo.InvariantCulture)
+1