方法的形参和实参
方法的形参和实参:
using System; namespace 方法的形参和实参 { class Program { static void Main(string[] args) { //比较两个数字的大小,返回最大的 int a1 = 10; int a2 = 20; int max= GetMax(a1,a2);//实参,实实在在的参数,参数的类型和个数要和形参匹配 Console.WriteLine(max); Console.ReadKey(); } public static int GetMax(int n1,int n2)//形参,形式上的参数,比较两个数字大小,你得给我两个数字呀。 { int max= n1 >n2 ? n1: n2; return max; } } }

浙公网安备 33010602011771号