为什么下面的代码在VB.net 2008中有错误?
Dim Object1 As New Class1
Object1.SetId = If(rbSet.Checked = True, Convert.ToInt32(txtSetId.Text.Trim()), DBNull.Value)
我正在尝试的是通过条件设置对象的属性。
答案 0 :(得分:2)
使用 Nothing
Object1.SetId = If(rbSet.Checked = True, Convert.ToInt32(txtSetId.Text.Trim()), Nothing)