Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7828903
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T10:31:54+00:00 2026-06-02T10:31:54+00:00

Hello I have a StreamWriter Called gameWriter. Can I use string builder to format

  • 0

Hello I have a StreamWriter Called gameWriter. Can I use string builder to format my Stream Writer? I want the result to look like this: playerOneName and playerTwoName are variables that need to be written. Can someone show me a sample code to show the following:

Output:
playerOnename, playerTwoname, _, _, _, _, _, _, _, _, _,


private void WriteData(string playerOneName, string playerTwoName)
    {
        StreamWriter gameStateWriter = null;

        try
        {
            gameStateWriter = new StreamWriter(filepath, true);
            gameStateWriter.WriteLine(playerOneName + " , " + playerTwoName);
        }
        catch (Exception ex)
        {
            txtOutcome.Text = "The following problem ocurred when writing to the file:\n"
               + ex.Message;
        }
        finally
        {
            if (gameStateWriter != null)
                gameStateWriter.Close();
        }
    }

Yes those are underscores, they are suppose to represent spaces are ready to be written on to hold some text.

i am using Visual Studio ’08 running ASP.NET website and form.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T10:31:55+00:00Added an answer on June 2, 2026 at 10:31 am

    That how to use stream writer with string builder although i would recommend use a loop to append to builder.

    StringBuilder builder = new StringBuilder();
    
    builder.Append(playerOneName)
    builder.Append(",")
    builder.Append(playerTwoName)
    builder.Append(",")
    StreamWriter  nameWriter = new StreamWriter(filepath, true);
    nameWriter.WriteLine(builder.ToString());
    

    you just store all your variables in array

    string[] names = {playerOneName, playerTwoName, playerThreName};
    foreach(string item in names)
    {
    
        builder.Append(item)
        builder.Append(",")
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hello I have a long string. I want to split it as some kind
Hello I have a problem I have Column data in string format in this
Hello have following strange issue, can vertical center the menu text if it's one
Hello I have one question about using genetic in correct way. please look at
Hello I have a var in a function when I hit submit...I want to
Hello, thanks for reading my question. I have a string that I need to
Hello I have a wordpress site than I want to upgrade to HTML5 code
Hello I have an api response in xml format with a series of items
Hello I have $string1, Array[] and $string2. I want to create a Arraynew[] such
Hello I have a view that deletes order numbers. Once a string has been

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.