一个无法识别的错误 [英] an unrecognized error

查看:107
本文介绍了一个无法识别的错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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 a DataTable but you try to use it like it was an array, you probably meant to access some column in row i, but for that you should use the Rows property of DataTable!
dt.Rows[i]["Title"]


这篇关于一个无法识别的错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆