简体   繁体   English

更新以使用 Option Strict On

[英]Updating to use Option Strict On

I am working on updating a VB.net project to use Option Strict On throughout and seeing this error:我正在更新 VB.net 项目以在整个过程中使用 Option Strict On 并看到此错误:

BC32013 Option Strict On disallows operands of type Object for operator '='. BC32013 Option Strict On 不允许 Object 类型的操作数用于运算符“=”。 Use the 'Is' operator to test for object identity.使用“是”运算符来测试 object 身份。

However when I try it the code does not work.但是,当我尝试它时,代码不起作用。

Code:代码:

If (dtg_FieldSelector.Rows.Item(m_int_SelectedRow).Cells(0).Value = txt_FieldIndex.Text) Then

you need to stringify the datagrid value as it is Object and Strict on forbids the comparison of two different datatypes您需要对数据网格值进行字符串化,因为它是Object并且 Strict on 禁止比较两种不同的数据类型

If (dtg_FieldSelector.Rows.Item(m_int_SelectedRow).Cells(0).Value.ToString() = txt_FieldIndex.Text) Then

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM