Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/264.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
ForEach C#WPF MVVM的LINQ语句值_C#_Linq - Fatal编程技术网

ForEach C#WPF MVVM的LINQ语句值

ForEach C#WPF MVVM的LINQ语句值,c#,linq,C#,Linq,如何将customer.CustomerTelephone的值输入到ForEach语句中?我已尝试使用customer.ToString(),但似乎不起作用。在这种情况下,您不想使用选择many。只需使用选择 在您的示例中,String.Format对您没有任何帮助 SelectedStationCustomers .SelectMany(customer => String.Format("{0}", customer.CustomerTelephone))

如何将customer.CustomerTelephone的值输入到ForEach语句中?我已尝试使用customer.ToString(),但似乎不起作用。

在这种情况下,您不想使用
选择many
。只需使用
选择

在您的示例中,
String.Format
对您没有任何帮助

SelectedStationCustomers
              .SelectMany(customer => String.Format("{0}", customer.CustomerTelephone))
              .ToList()
              .ForEach(customer => client.SendMessage("12345678", NEED VALUE HERE, textMessage));

在这种情况下,您不想使用
SelectMany
。只需使用
选择

在您的示例中,
String.Format
对您没有任何帮助

SelectedStationCustomers
              .SelectMany(customer => String.Format("{0}", customer.CustomerTelephone))
              .ToList()
              .ForEach(customer => client.SendMessage("12345678", NEED VALUE HERE, textMessage));

我将使用Select而不是SelectMany:

SelectedStationCustomers
.Select(customer=>String.Format(“{0}”,customer.CustomerTelephone))
托利斯先生()

.ForEach(customer=>client.SendMessage(“12345678”,customer,textMessage))我将使用Select而不是SelectMany:

SelectedStationCustomers
.Select(customer=>String.Format(“{0}”,customer.CustomerTelephone))
托利斯先生()

.ForEach(customer=>client.SendMessage(“12345678”,customer,textMessage))
customer.ToString()
.ForEach()
中提供了什么?为什么要使用SelectMany?这将产生一个
IEnumerable
。只需使用选择。请保留与问题相关的标签,而不是您的项目。另外,您忘记了、和标记。
customer.ToString()
.ForEach()
中提供了什么?为什么要使用SelectMany?这将产生一个
IEnumerable
。只需使用选择。请保留与问题相关的标签,而不是您的项目。还有,你忘了,还有标签。非常感谢。这就解决了问题。我使用SelecMany是因为我最初有更多的列要选择,而我拿走了这些列。SelectMany不用于选择多个列。SelectMany用于将多个序列展平为一个序列()。如果要选择多个列,请执行此操作
select(x=>new{x.Field1,x.Field2})
等。非常感谢。这就解决了问题。我使用SelecMany是因为我最初有更多的列要选择,而我拿走了这些列。SelectMany不用于选择多个列。SelectMany用于将多个序列展平为一个序列()。如果要选择多个列,请执行以下操作
select(x=>new{x.Field1,x.Field2})
等。