Line changment in streamWriter and sensitive replace method
-
Hello. I have 2 questions for you Question 1: I got this method:
private void writeData()
{
StreamWriter writer = new StreamWriter(saveMonsterSetBase.FileName, false);for (int i = 0; i < MonsterSetBaseDataArray.Count; i++) { writer.Write(MonsterSetBaseDataArray\[i\]); } writer.Close(); }
Which sort of works It writes data from my arraylist to a file The problem is it writes it in one line. If my arraylist is like this: line 1 line 2 line 3 It writes in the file like this: line 1 line 2 line 3 How can I make a line changment? Question 2: I have a string that looks like this: string testString = "1 10"; and I want to replace 1 and 10 with something I replace it like this: testString.Replace("1", "One").Replace("10", "Ten"); But the problem is that the output for 10 comes out as OneTen Is there any way to replace 1 as just One and 10 as just Ten?
-
Hello. I have 2 questions for you Question 1: I got this method:
private void writeData()
{
StreamWriter writer = new StreamWriter(saveMonsterSetBase.FileName, false);for (int i = 0; i < MonsterSetBaseDataArray.Count; i++) { writer.Write(MonsterSetBaseDataArray\[i\]); } writer.Close(); }
Which sort of works It writes data from my arraylist to a file The problem is it writes it in one line. If my arraylist is like this: line 1 line 2 line 3 It writes in the file like this: line 1 line 2 line 3 How can I make a line changment? Question 2: I have a string that looks like this: string testString = "1 10"; and I want to replace 1 and 10 with something I replace it like this: testString.Replace("1", "One").Replace("10", "Ten"); But the problem is that the output for 10 comes out as OneTen Is there any way to replace 1 as just One and 10 as just Ten?
Soloution found: 1: [writer.WriteLine(MonsterSetBaseDataArray); 2: testString.Replace("10", "Ten").Replace("1", "One");