Main contents of the function

Source: Internet
Author: User

namespace function
{//function: To improve the reusability of code, a block of closed blocks of code.
//Syntax structure: The return value (the data type of the result returned after executing the function), function name, input parameter, output parameter, function body.
//One: No return value, no parameter function
/* public void Dayin ()//Just call, no return value required
{
Console.WriteLine ("Hello,world");
}
*/
/*public void Jiafa ()
{
int a = Convert.ToInt32 (Console.ReadLine ());
int b = Convert.ToInt32 (Console.ReadLine ());
Console.WriteLine (A+B);
}
*/

//Two: With return value, no parameter
//Three: With a return value, with input parameters
/* public string Caiquan (int a,int b)
{
String S= "";
if (A-b = = 1 | | A-b = 2)
{
S= "man wins";
}
else if (a = = b)
{
S= "Draw";
}
Else
{
s= "Computer wins";
}
return s;
}
* */
//Four: With return value, with input/output parameters
Class Program
{
public void Jiafa ()
//{
int a = Convert.ToInt32 (Console.ReadLine ());
int b = Convert.ToInt32 (Console.ReadLine ());
Console.WriteLine (A+B);
//}


public int/* return value * /qiuhe/*output function */(int n/* Input function */)
//{
int sum = 0; //Final summation result
for (int i = 0; I <= N; i++)
//    {
sum = sum + i;
//    }
return sum;
//}

public void Dayin ()//Just call, no return value required
//{
Console.WriteLine ("Hello,world");
//}
public string Caiquan (int a,int b)
{
String S= "";
if (A-b = = 1 | | A-b = 2)
{
S= "man wins";
}
else if (a = = b)
{
S= "Draw";
}
Else
{
s= "Computer wins";
}
return s;
}

static void Main (string[] args)
{

//Enter a number, add sum
Console.WriteLine ("Please enter a number:");
int shu = Convert.ToInt32 (Console.ReadLine ());

int sum=new Program (). Qiuhe (SHU);
Console.WriteLine (sum);

New program (). Dayin ();

New program (). Jiafa ();

Console.WriteLine ("Please enter a number: 0-Scissors 1-Cloth 2-stone");
int a = Convert.ToInt32 (Console.ReadLine ());
Random r = new Random ();
int B = R.next (3);
Console.WriteLine ("Computer Out" +b);
String jieguo= new Program (). Caiquan (A, b);
Console.WriteLine (Jieguo);
Console.ReadLine ();
}
}
}

Main contents of the 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.