2011-01-20 85 views
0

为什么下面的代码在VB.net 2008中有错误?VB.net:通过条件设置“NULL”属性?

Dim Object1 As New Class1 

Object1.SetId = If(rbSet.Checked = True, Convert.ToInt32(txtSetId.Text.Trim()), DBNull.Value) 

我想要的是通过条件来设置对象的属性。

+0

什么数据类型是`SetId`财产,什么是错误讯息? – 2011-01-20 14:06:22

回答

2

使用没有

Object1.SetId = If(rbSet.Checked = True, Convert.ToInt32(txtSetId.Text.Trim()), Nothing)