Yes, you can assign a value to a variable inside an IF condition in VB.NET. There is even built-in support for this, although to a limited extent:
If Interlocked.Exchange(customer, GetCustomer(id)) Is Nothing Then Return False End If
where the methods in the Interlocked class are intended for use in a multi-threaded environment. In design, the return value of Exchange () is the old value, not the new one. Thus, to get a rather cryptic equivalent result:
If (customer = Interlocked.Exchange(customer, GetCustomer(id)) And customer Is Nothing Then return false End If
source share