Unlike a = b = 5 in VB.NET - impossible?, I am specifically asking for an extension method to overcome this.
In C#, you can do something like this, which is very helpful:
a = b = c = 16;
All variables end up being 16. One of the answers in Why do assignment statements return a value? gives reasons why this is handy.
But in VB.Net, if you do:
Dim a, b, c As Integer
a = b = c = 16
All you get are 0's for a, b, and c.
I want to defeat this limitation by an extension method. Can this be done?
EDIT:
Here is the closest answer I personally could come up with:
<System.Runtime.CompilerServices.Extension()>
Public Function Assign(ByRef Operand1 As Object, ByRef Operand2 As Object) As Object
Operand1 = Operand2
Return Operand1
End Function
Even though it allows you do do this,
Dim a, b, c As Integer
a.Assign(b.Assign(c.Assign(16)))
it sure is clunky and imo harder to follow, but it's the closest thing to an direct answer to my actual question I could find. I welcome any improvements.