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