Write List>> to text file?

前端 未结 3 1890
萌比男神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:39

    You could use String.Join to concatenate your List into a single string with a given delimiter:

    File.WriteAllLines(@"C:\Users\S\Downloads\output.txt",
            xEleAtt.Select(x => x.Key + " Val's: " + 
            string.Join(",", x.Value.ToArray()).ToArray());
    

提交回复
热议问题