C# 中调用方法
可以使用方法名调用方法: 在同一个类里面调用方法和在类之间调用方法public 声明方法
using System;
namespace DisApplication{
class Program{
public int FindMax(int num1, int num2)
{
int result;
if (num1 > num2)
result = num1;
else
result = num2;
return result;
}
}
class SecondProgram{
static void Main(string[] args)
{
Program p = new Program();
int results = p.FindMax(100,200);
Console.WriteLine("Max = {0}",results);
SecondProgram s = new SecondProgram ();
int min = s.FindMin (1000, 5000);
Console.WriteLine("Min = {0}",min);
Console.ReadLine();
}
public int FindMin(int num1, int num2)
{
int min;
if (num1 > num2)
min = num2;
else
min = num1;
return min;
}
}
}