Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Line changment in streamWriter and sensitive replace method

Status
Not open for further replies.

leprogrammer

Programmer
Mar 21, 2008
25
DK
Hello.

I have 2 questions for you

Question 1:
I got this method:

Code:
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?
 
Try:

1:
[tt][writer.WriteLine(MonsterSetBaseDataArray);[/tt]

2:
testString.Replace("10", "Ten").Replace("1", "One");


But the problem is that the output for 10 comes out as OneTen

I would have thought that you would get One0, not OneTen


[vampire][bat]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top