nedcomp hosting homepage

Producten en diensten
Dedicated servers
Datacenter informatie
Partners, resellers
Helpdesk informatie
Technische docs, tools
Support homepage
ASP componenten
Praktische ASP, ASP.NET
Visual route server
Whois (domein gegevens)
Software documentatie
Whitepapers
Zoeken
Nedcomp / algemeen

Zoeken
 

Copyright © Nedcomp Hosting
Telefoon nr :   +31 184 670111
Fax nummer :   +31 184 631384
E-mailadres :   info@nedcomp.nl
 

C# Programmer's Reference  

return

The return statement terminates execution of the method in which it appears and returns control to the calling method. It can also return the value of the optional expression. If the method is of the type void, the return statement can be omitted. This statement takes the following form:

return [expression];

where:

expression
The value returned by a method. The expression is not used with methods of the type void.

Example

In the following example, the method A() returns the variable Area as a double value.

// statements_return.cs
using System;
class ReturnTest 
{
   static double CalculateArea(int r) 
   {
      double area;
      area = r*r*Math.PI;
      return area;
   }

   public static void Main() 
   {
      int radius = 5;
      Console.WriteLine("The area is {0:0.00}", CalculateArea(radius));
   }
}

Output

The area is 78.54

See Also

C# Keywords | <_pluslang_the_c.2b2b_.return_statement>Compare to C++ | Jump Statements | C. Grammar