Day 12th (function)

Source: Internet
Author: User

Function:

The function is written under program, void means no return value, and the object in () represents the parameter

1. No return value no parameters

public void AA ()

{

}

2. There are no return values for parameters

public void AA (int a)

{

}

3. There is no parameter for return value

public double AA ()

{

}

4. There are parameters for return values

public double aa (int a)

{

}

Public means that functions are common, and other CS can also reference

Usage:

Program B=new program ();

B.aa ();

Cases

1   class Program2     {3                Public DoubleMaxDoubleADoubleb)4         {5             if(A >b)6             {7                 returnA;8             }9             ElseTen             { One                 returnb; A             } -        } -  the  -  Static voidMain (string[] args) -         {            -Console.Write ("Please enter the first number:"); +             DoubleA =int. Parse (Console.ReadLine ()); -Console.Write ("Please enter a second number:"); +             Doubleb =int. Parse (Console.ReadLine ()); AConsole.Write ("Please enter a third number:"); at             Doublec =int. Parse (Console.ReadLine ()); -Program Daxiao =NewProgram (); -             DoubleD =Daxiao.max (c, Daxiao.max (A, b)); - Console.Write (d); -         } -}

Day 12th (function)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.