Click here to Skip to main content
15,117,095 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i read about the return jump statmnet in c# but i didnt get the meaning of the last part of the word
"This statement terminates the execution of the method and <big><big><big></big></big>returns the control to the calling method</big>"

What I have tried:

read about it in microsoft docs
Updated 9-Jul-19 13:01pm

void SomeMethod()
   // ...

void Main()
   // Code executed before the call to the SomeMethod method
   // Code executed after the SomeMethod method has exited

In the Main method, there is a call to the SomeMethod method. Thus, the execution goes from the Main method to the SomeMethod method. When the return; statement is reached, the SomeMethod exits and returns execution to the calling method, i.e. the Main method.
Member 14479161 9-Jul-19 21:00pm
Here the caller method is the main Method correct
phil.o 10-Jul-19 2:55am
Member 14479161 10-Jul-19 10:37am
What this means is that if the conditions are met, an earlier departure from the routine occurs, and the rest of the routine is ignored. In this example, calls to will return a -1 right away if the input value not a valid email address, and not go through the overhead of building objects and running their methods. While you could just put the rest of the code in an else wrap, you'd stilll have to go through all of the code when you are debugging.
public static class generate{
  public int email(string emailAddress = "") {
    if (IsValidAddress(emailAddress) == false) {       return -1;     }

    // build smtp object
    // build mail message
    // try to send message
    // log results

   return send.resultvalue;

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900