可选参数
using System;class Program
{
static void Main()
{
Console.WriteLine(ShowComputer());
Console.WriteLine(ShowComputer("P5300","1G"));
Console.Read();
}
private static string ShowComputer(string cpu = "2.4Ghz" , string ram = "2g" , string disk = "500g")
{
return "My computer ... \nCpu:" + cpu + "\nRam:" + ram + "\nDisk:" + disk + "\n";
}
}
怎样才能使这段代码运行,还有问一下参数的价值究竟是什么,用变量不已经是很好了吗?谢谢