一个无法识别的错误 [英] an unrecognized error
本文介绍了一个无法识别的错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
hi
当我写下以下命令时:
TreeNode myTn = new TreeNode(System.Convert.ToString(dt [i] [Title ]);
编译后显示此错误
错误:无法将带有[]的索引应用于类型为'System'的表达式。 Data.DataTable'
谢谢
hi
when i write following command:
TreeNode myTn = new TreeNode(System.Convert.ToString(dt[i]["Title"]));
this error be shown after compile
Error:Cannot apply indexing with [] to an expression of type 'System.Data.DataTable'
thanks
推荐答案
尝试:
dt.Rows[i]["Title"]
检查dt - 编译器声明它是DataTable
但是你尝试使用它就像它是一个数组,你可能想要访问行i
中的一些列,但为此你应该使用行
属性DataTable
!
Check dt - the compiler states that it is aDataTable
but you try to use it like it was an array, you probably meant to access some column in rowi
, but for that you should use theRows
property ofDataTable
!
dt.Rows[i]["Title"]
这篇关于一个无法识别的错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文