.NET use IIF to assign value to different variables

Could I (and if so how) do the following in .NET language (more specifically VB.NET):

Dim a,b as Integer
if(somecondition=1,a,b) = 12345

Or any variant with IIF would be fine by me. Basically I'm always assign the same value but never to the same variable..

Jon Skeet
people
quotationmark

No, I don't believe there's any way of doing that in VB. Conditional operators (such as If(x, y, z)) are designed to evaluate one expression or the other based on a condition. In other words, it's the result that's conditional, not the use of it.

Just use a normal If statement:

If somecondition Then
    a = 12345
Else
    b = 12345
End If

Or to avoid repeating the value (e.g. if it's a more complicated expression):

Dim value As Integer = 12345
If somecondition Then
    a = value
Else
    b = value
End If

people

See more on this question at Stackoverflow