After converting a method to a delegate, the IDE now tells me every instance of a call to this method is a case of “This is not an array but you are using it as one”, which makes no sense.
Here’s what I did:
created a delegate MyDelegate with the same parameters as the original method MyMethod
made a property of MyMethod of type MyDelegate
assigned in code: MyMethod = WeakAddressOf MyDelegate
And when I try to compile, now I get all these (incorrectly identified) “This is not an array but you are using it as one” errors. What have I done wrong?
Oh no, (this is embarrassing) here is what I forgot …
The method calls all need to be changed to .invoke
So, for anyone else who ran into this, the process needs to be:
create a delegate MyDelegate with the same parameters as the original method MyMethod
make a property of MyMethod of type MyDelegate
assign in code: MyMethod = WeakAddressOf MyDelegate
search and replace all your method calls MyMethod with MyMthod.Invoke
Then it works. The error makes sense if you see that since the method is now a property (of type MyDelegate) then sending the parameters to that method name MyMethod( parameters ) without .Invoke makes the compiler see that you are trying to treat the property as an array. When it is MyMethod.Invoke( parameters ) then it is correct syntax for the delegate class.