Can we use If condition in With Keyword ? I am adding items to the class using with in VB.Net. I want to validate one condition before adding. I want to validate isActive with if condition in below Code.
For i As Integer = 0 To currWf.Tables(0).Rows.Count - 1
wfChartDataItemCollection.Add(New WfChartDataItem() With { _
.Index = Convert.ToInt32(currWf.Tables(0).Rows(i)("StatusID").ToString()), _
.isActive = True, _
.Title = Convert.ToInt32(currWf.Tables(0).Rows(i)("RoleID").ToString()), _
.Description = currWf.Tables(0).Rows(i)("Description").ToString() _
})
Next
If your isActive property is a boolean value (meaning it can be set to either True or False) then you can also set it equal to a comparison that you would perform in an If Statement :
ramll
Participant
1126 Points
1299 Posts
if COndition in WIth Keyword
Jan 18, 2013 03:48 PM|LINK
Hello,
Can we use If condition in With Keyword ? I am adding items to the class using with in VB.Net. I want to validate one condition before adding. I want to validate isActive with if condition in below Code.
For i As Integer = 0 To currWf.Tables(0).Rows.Count - 1 wfChartDataItemCollection.Add(New WfChartDataItem() With { _ .Index = Convert.ToInt32(currWf.Tables(0).Rows(i)("StatusID").ToString()), _ .isActive = True, _ .Title = Convert.ToInt32(currWf.Tables(0).Rows(i)("RoleID").ToString()), _ .Description = currWf.Tables(0).Rows(i)("Description").ToString() _ }) NextRion William...
All-Star
26445 Points
4389 Posts
Re: if COndition in WIth Keyword
Jan 18, 2013 03:59 PM|LINK
Sure!
If your isActive property is a boolean value (meaning it can be set to either True or False) then you can also set it equal to a comparison that you would perform in an If Statement :