Write List>> to text file?

前端 未结 3 1921
萌比男神i
萌比男神i 2021-01-27 07:37

I was wondering if anyone knows a good way of writing this. I have a list of key value pairs. The key is a simple string and the value is a list of strings. I\'m trying to write

3条回答
  •  不要未来只要你来
    2021-01-27 07:47

    File.WriteAllLines(@"C:\Users\S\Downloads\output.txt",
             xEleAlt.SelectMany(x=> x.Value, (x,y)=> x.Key + " Val's: " + y).ToArray());
    
    //Result
    Queue0  ....
    Queue0  ....
    ......
    Queue1  ....
    Queue1  ....
    ....
    

    NOTE: I'm not sure if you want to join all the strings in the List to make the value for each entry. If you want so, refer the answer of Douglas

提交回复
热议问题