我想了解這條線從RelayCommand例如採取的含義和使用PARAM參數:如何使用C#中的「param」工作來獲得此示例?
return new RelayCommand(param => MessageBox.Show("It worked."));
首先,據我所知,「參數」參數有無關的「params」關鍵字,這是正確的嗎?
public int Add(params int[] list)
{
int sum = 0;
foreach (int i in list)
sum += i;
return sum;
}
其次,什麼樣的代碼,代表我要補充得到下面的示例工作?
using System;
using System.Collections.Generic;
namespace TestParam222
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("The total is {0}.", Tools.GetTest(param => 23));
Console.ReadLine();
}
}
class Tools
{
public static string GetTest(List<int> integers)
{
return "ok";
}
}
}
param不是關鍵字。 – 2009-04-16 13:49:30