C# Return Statement

return-statements
In this chapter you will learn:

  • What is the return statement in C#?
  • What is the functionality of return statement?
  • How to use return statement in programming?

A return statement is used for returning value to the caller from the called function. A easy example is mentioned below in a program that demonstrate the return statement very clearly.

Example:


In this example the variable result calls the function add() with two parameters and the function add() returns addition of both number to the result variable using return keyword.

Output

9
__

Summary

In this chapter you learned what return statement is in C# and how to use it in programming. In next chapter you will learn throw statement in C#.


Leave a Reply

Your email address will not be published. Required fields are marked *