列表列表中的项目未显示 [英] item in a list of a list is not beeing displayed
问题描述
它向我显示了idfichier,nomclient显示了system.linq.enumerable ... 我猜它显示的是nomclient的类型.
it shows me the idfichier, and the nomclient shows system.linq.enumerable... I guess it is showing the type of nomclient.
public static void generateCTAF(string pathXml, string outputPDF)
{
List<FichierCTAF> fc = new List<FichierCTAF>();
fc = getXmlFCtaf(pathXml);
foreach (FichierCTAF f in fc)
{
Console.WriteLine("ID CTAF : {0} \n Nom Client : {1}\n \n", f.IdFichierCtaf, f.Clients.Select(y => y.NomClient ));
}
}
该如何显示?图片显示了我得到的结果
How can I display that? the picture displays the result that i got
推荐答案
您会看到奇怪的System.Linq.Enumerable+WhereSelectListIterator
,因为它是列表迭代器的ToString()
表示形式,由f.Clients.Select(y => y.NomClient)
查询返回.
You see that strange System.Linq.Enumerable+WhereSelectListIterator
because it's ToString()
representation of list iterator, which is returned by f.Clients.Select(y => y.NomClient)
query.
如果需要显示所有NomClient
值,建议您建立它们的串联字符串:
If you need to display all NomClient
values, I suggest you to build concatenated string of them:
public static void generateCTAF(string pathXml, string outputPDF)
{
List<FichierCTAF> fc = getXmlFCtaf(pathXml);
foreach (FichierCTAF f in fc)
{
Console.WriteLine("ID CTAF : {0}\n Nom Client : {1}\n\n",
f.IdFichierCtaf,
String.Join(", ", f.Clients.Select(y => y.NomClient)));
}
}
或者您可以枚举NomClients
值并将其打印在自己的行上:
Or you can enumerate NomClients
values and print each on its own line:
public static void generateCTAF(string pathXml, string outputPDF)
{
List<FichierCTAF> fc = getXmlFCtaf(pathXml);
foreach (FichierCTAF f in fc)
{
Console.WriteLine("ID CTAF : {0}", f.IdFichierCtaf);
foreach(string nomClient in f.Clients.Select(y => y.NomClient))
Console.WriteLine(" Nom Client : {0}", nomClient);
}
}
这篇关于列表列表中的项目未显示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!