Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. writing quotes with data to a text file..not quite what I wanted as output

writing quotes with data to a text file..not quite what I wanted as output

Scheduled Pinned Locked Moved C#
csharpquestion
6 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • L Offline
    L Offline
    LongRange Shooter
    wrote on last edited by
    #1

    I have a variable I need to add to an output string for generating some C# code. The intent is the line should be ConfigurationManager.ConnectionString["Talker"].ToString(); and the code to generate that line is as such:

                StringBuilder conName = new StringBuilder();
                conName.Append("\\t\\t\\t\\t\\t\\t");
                conName.Append("ConfigurationManager.ConnectionStrings\[\\"");
                conName.Append(parameters.UseConnectionStringName);
                conName.Append("\\"\].ToString();");
            swBaseClass.WriteLine( conName.ToString() );
    

    When I look at conName it is formatted correctly. ConfigurationManager.ConnectionString["Talker"].ToString(); When I view the resulting code the line reads ConfigurationManager.ConnectionString[""].ToString(); Any suggestions on why my variable name is not being written out???

    P L 3 Replies Last reply
    0
    • L LongRange Shooter

      I have a variable I need to add to an output string for generating some C# code. The intent is the line should be ConfigurationManager.ConnectionString["Talker"].ToString(); and the code to generate that line is as such:

                  StringBuilder conName = new StringBuilder();
                  conName.Append("\\t\\t\\t\\t\\t\\t");
                  conName.Append("ConfigurationManager.ConnectionStrings\[\\"");
                  conName.Append(parameters.UseConnectionStringName);
                  conName.Append("\\"\].ToString();");
              swBaseClass.WriteLine( conName.ToString() );
      

      When I look at conName it is formatted correctly. ConfigurationManager.ConnectionString["Talker"].ToString(); When I view the resulting code the line reads ConfigurationManager.ConnectionString[""].ToString(); Any suggestions on why my variable name is not being written out???

      P Offline
      P Offline
      PIEBALDconsult
      wrote on last edited by
      #2

      Dunno... do you need to add .Value to parameters.UseConnectionStringName or something?

      L 1 Reply Last reply
      0
      • P PIEBALDconsult

        Dunno... do you need to add .Value to parameters.UseConnectionStringName or something?

        L Offline
        L Offline
        LongRange Shooter
        wrote on last edited by
        #3

        Please read the entire post. The text existed as a string correctly. If you do not know, then why post a reply?

        P 1 Reply Last reply
        0
        • L LongRange Shooter

          Please read the entire post. The text existed as a string correctly. If you do not know, then why post a reply?

          P Offline
          P Offline
          PIEBALDconsult
          wrote on last edited by
          #4

          I did, and saw nothing wrong, and now I've read it again and still don't. Are you saying that when you inspect the StringBuilder in debug you see the whole value, but when you write it out you don't? What are you using to vew the resultant file?

          1 Reply Last reply
          0
          • L LongRange Shooter

            I have a variable I need to add to an output string for generating some C# code. The intent is the line should be ConfigurationManager.ConnectionString["Talker"].ToString(); and the code to generate that line is as such:

                        StringBuilder conName = new StringBuilder();
                        conName.Append("\\t\\t\\t\\t\\t\\t");
                        conName.Append("ConfigurationManager.ConnectionStrings\[\\"");
                        conName.Append(parameters.UseConnectionStringName);
                        conName.Append("\\"\].ToString();");
                    swBaseClass.WriteLine( conName.ToString() );
            

            When I look at conName it is formatted correctly. ConfigurationManager.ConnectionString["Talker"].ToString(); When I view the resulting code the line reads ConfigurationManager.ConnectionString[""].ToString(); Any suggestions on why my variable name is not being written out???

            L Offline
            L Offline
            LongRange Shooter
            wrote on last edited by
            #5

            was using new code that used the wrong field.....DOH

            1 Reply Last reply
            0
            • L LongRange Shooter

              I have a variable I need to add to an output string for generating some C# code. The intent is the line should be ConfigurationManager.ConnectionString["Talker"].ToString(); and the code to generate that line is as such:

                          StringBuilder conName = new StringBuilder();
                          conName.Append("\\t\\t\\t\\t\\t\\t");
                          conName.Append("ConfigurationManager.ConnectionStrings\[\\"");
                          conName.Append(parameters.UseConnectionStringName);
                          conName.Append("\\"\].ToString();");
                      swBaseClass.WriteLine( conName.ToString() );
              

              When I look at conName it is formatted correctly. ConfigurationManager.ConnectionString["Talker"].ToString(); When I view the resulting code the line reads ConfigurationManager.ConnectionString[""].ToString(); Any suggestions on why my variable name is not being written out???

              P Offline
              P Offline
              PIEBALDconsult
              wrote on last edited by
              #6

              If you don't need the StringBuilder for anything else, why not eliminate it?

              swBaseClass.WriteLine
              (
              "\t\t\t\t\t\tConfigurationManager.ConnectionStrings[\"{0}\"].ToString();"
              ,
              parameters.UseConnectionStringName
              ) ;

              1 Reply Last reply
              0
              Reply
              • Reply as topic
              Log in to reply
              • Oldest to Newest
              • Newest to Oldest
              • Most Votes


              • Login

              • Don't have an account? Register

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • World
              • Users
              • Groups