Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Saving lists to txt file

Tags:

c#

list

I'm trying to save a list to a text file.

This is my code:

public void button13_Click(object sender, EventArgs e) {     TextWriter tw = new StreamWriter("SavedLists.txt");      tw.WriteLine(Lists.verbList);     tw.Close(); } 

This is what I get in the text file:

System.Collections.Generic.List`1[System.String]

Do I have to use ConvertAll<>? If so, I'm not sure how to use that.

like image 752
Jared Price Avatar asked Mar 08 '13 18:03

Jared Price


People also ask

How do I convert a list to a text file in Python?

Python read file into list. To read a file into a list in Python, use the file. read() function to return the entire content of the file as a string and then use the str. split() function to split a text file into a list.


1 Answers

Framework 4: no need to use StreamWriter:

System.IO.File.WriteAllLines("SavedLists.txt", Lists.verbList); 
like image 115
Eric Bole-Feysot Avatar answered Sep 19 '22 20:09

Eric Bole-Feysot