Ano*_*urn 0 c# methods wpf parameter-passing
伙计我将一些参数传递给WPF应用程序的新窗口,如下所示
List<string[]> liststat = conf.getlistbytype(type);
if ((liststat == null) || (liststat.Count == 0))
{
MessageBox.Show("There is no stat of that type in this stat server");
}
else
{
CalculatedStat3 prompt = new CalculatedStat3(statwin, conf, liststat, this);
prompt.Show();
Run Code Online (Sandbox Code Playgroud)
但是目标页面的构造者是
public CalculatedStat3(statwindow statwin, ConfigLayer conf, string[] statsname, CalculatedStat2 backscreen)
{
}
Run Code Online (Sandbox Code Playgroud)
我应该怎么做才能纠正这个,因为我得到一个错误
'RCCV_Version_2.CalculatedStat3.CalculatedStat3(RCCV_Version_2.statwindow, rmad_wpf_lib.ConfigLayer, string[], RCCV_Version_2.CalculatedStat2)' has some invalid arguments
Run Code Online (Sandbox Code Playgroud)
第一个解决方案,只获得第一个阵列
CalculatedStat3 prompt = new CalculatedStat3(statwin, conf, liststat.First(), this);
Run Code Online (Sandbox Code Playgroud)
其次,压扁你的收藏
var stats = liststat.SelectMany(x=>x).ToArray();
CalculatedStat3 prompt = new CalculatedStat3(statwin, conf, stats, this);
Run Code Online (Sandbox Code Playgroud)
在第一个解决方案中,您将只获得第一组统计数据,在第二个解决方案中,您将获得大量连接的所有统计数据.我认为秒解决方案符合您的要求.