I have a method that takes an System.Action, this is what I’m trying to feed it:
Function() Me._existingImports = Me.GetImportedAds()
The thing is that it complains about the = sign since it thinks I’m trying to do a comparison, which I’m not. I want to assign the Me._existingImports the value of Me.GetImportedAds(), but VB.NET complains about DataTable not having a = operator.
How can I force it to use the assignment operator instead of the equality operator?
In C# this works perfectly fine:
() => this.existingImports = this.GetImportedAds()
For now the solution will be to use a standalone method, but that’s way more code than needed.
When using
Function(), you really define an anonymous function which means you map values to values.Therefore
Function()strictly needs an expression (likexor42…) as the body, which an assignment is not! (Assignments don’t evaluate to values like in C-style languages in VB)Thus what you need is not a
Function()but aSub(), which contains statements (actions) rather than values.C# doesn’t distinguish here, the (much nicer)
... => ...syntax covers it all.