c# when action is not void





Imagine that we're passing have a method that accept Action as a parameter.


public void Invoke(Action action){  /*Code Here */ }
And if we pass something like this 


public void Invoke(Action action){ /*Code Here */ }
public void WriteSomething() { Console.WriteLine('test'); }

We get an error cannot convert void to System.Action.

In reality we're passing void back which is wrong. We should invoke it like so,


Invoke(() => { /* code here */ } 
Invoke(() => { UpdateSomething(localVar1, localVar2, localVar3); } 





Comments

Popular posts from this blog

The specified initialization vector (IV) does not match the block size for this algorithm