Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can a method do a return on the calling method? c#

Tags:

c#

return

Can a method do a return on the calling method?

void Main()
{
   Returner(); //how can i return here... 
   DoNotCallDueToReturn();
}

void Returner()
{
   return //... from here?
}

DoNotCallDueToReturn()
{
   Console.WriteLine("You failed to return");
}
like image 730
4imble Avatar asked May 09 '26 16:05

4imble


1 Answers

Your second method would have to return a value:

int Main()
{
    return Returner();
}

int Returner()
{
    return something;
}
like image 51
Justin Niessner Avatar answered May 11 '26 04:05

Justin Niessner



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!