抄自 VB的。看來還是許多人要求這樣的功能。
class Program
{
static void Main(string[] args)
{
M(5);
M(10, 13);
M(y: 13, x: 10); //named parameters,有點像 T-SQL 的 stored procdure
}
static void M(int x, int y = 7)
{
Console.WriteLine("x = {0}, y = {1}", x, y);
}
}
當參數一多時,named parameters 就顯示特別好用囉!
沒有留言:
張貼留言