Advertisement
Help Keep Boards Alive. Support us by going ad free today. See here: https://subscriptions.boards.ie/.
If we do not hit our goal we will be forced to close the site.

Current status: https://keepboardsalive.com/

Annual subs are best for most impact. If you are still undecided on going Ad Free - you can also donate using the Paypal Donate option. All contribution helps. Thank you.
https://www.boards.ie/group/1878-subscribers-forum

Private Group for paid up members of Boards.ie. Join the club.

C# StringBuilder Issue

  • 23-03-2007 03:01PM
    #1
    Registered Users, Registered Users 2 Posts: 1,991 ✭✭✭


    I have the below code:
    for(j = 0; j < strArray.Length; j++)
    {
         strBuild.Replace(strArray[j], " ");
    }
    sw.Write(strBuild.ToString());
    

    The sw.Wrtie line has to be called everytime for the replace line to work but my problem is i can't put the sw.write line into the loop as its only ment to be called once.
    This way works fine:
    strBuild.Replace("name", " ");
    strBuild.Replace("age", " ");
    strBuild.Replace("address" " ");
    
    sw.Write(strBuild.ToString());
    
    Any ideas how to get the loop working with it???


Comments

  • Closed Accounts Posts: 4,943 ✭✭✭Mutant_Fruit


    The sw.Wrtie line has to be called everytime for the replace line to work but my problem is i can't put the sw.write line into the loop as its only ment to be called once.
    So, do you want to call it *once* or *every time*? Its hard to tell.


  • Registered Users, Registered Users 2 Posts: 1,991 ✭✭✭Ziycon


    Just want to call the sw.Write line once!


Advertisement