What is Return Type

    Return Type  specifies the output type of a function.
The output type can be a number,text etc..

If output of function is a number, the return type may be int or float or decimal etc..
If output of function type is text, the return type will be string etc..

The output type( return type )  can be a user defined class or struct or interface or enum or any type.

C#.NET Return Type Example

using System;


//Sample program to demonstrate return types

//Request  user to input 2 numbers and print the sum

namespace ProgramCall


    class Program


        static void Main(string[] args)



            int num1 = 0;

            int num2 = 0;


            Console.WriteLine("Enter any 2 numbers ");


            //Console.Readline returns of type string , so converting it to  int.

            num1 = int.Parse(Console.ReadLine());

            num2 = int.Parse(Console.ReadLine());



            //The function FindSum returns of type int so we are storing it in int  variable.

            int sum = FindSum(num1, num2);


            Console.WriteLine("Sum of  {0}  and {1}  is  {2} ", num1, num2, sum);





        //The function outputs of type integer, so return type is declared as int.

        private static int FindSum(int x, int y)


            return (x + y);





Output of above return type sample

Enter any 2 numbers
Sum of 45 and 80 is 125

return type C#.NET , return types, what is return type, function return type, method return type