Click here to Skip to main content
16,004,529 members
Please Sign up or sign in to vote.
1.44/5 (2 votes)
See more:
HELLO EVERYONE!

Please Tell Me HOW TO EXIT FROM THE FUNCTION WITHOUT EXIT FRO THE APPLICATION/PROGRAM IN C#.
Posted
Comments
[no name] 4-Sep-14 7:01am    
Is Gihan answer clearing ur doubts or not, or any more question
Member 11004573 4-Sep-14 8:41am    
Can You Please Explain me His Answer With One Example .Because it will be Easy for me.

1 solution

Two ways to exit a method without quitting the program

Use the return keyword.
Throw an exception.

C#
void Function()
{
    if(needToLeave)
        return;
}
 
Share this answer
 
v2
Comments
CPallini 4-Sep-14 6:15am    
5.
Gihan Liyanage 4-Sep-14 6:17am    
Thank you..
Gihan Liyanage 15-Sep-14 6:27am    
Did you got a solution from my support, I can see you have not accepted any answer.If you are ok with this answer plz accept it. Then any user having same problem can identified it has solved the problem..

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