private void SaveMoney(string id...)
{
...
}
public void DoSthWithMoney(string action,string id...)
{
if(action=="save") return SaveMoney(string id);
...
}
Why won't C# let me return the void of the private function back through the public function? It even is the same data type "void"...
Or isn't void a data type?
Is the following code really the shortest workaround?
if(action=="save") {
SaveMoney(string id);
return;
}
void
is not a type in C#. In this instance, void
means the absence of a return type or value so you cannot use it with return
as you have in the first example.
This is different to C, for example, where void can mean typeless or an unknown type.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With