writing quotes with data to a text file..not quite what I wanted as output
-
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 readsConfigurationManager.ConnectionString[""].ToString();
Any suggestions on why my variable name is not being written out??? -
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 readsConfigurationManager.ConnectionString[""].ToString();
Any suggestions on why my variable name is not being written out???Dunno... do you need to add
.Value
toparameters.UseConnectionStringName
or something? -
Dunno... do you need to add
.Value
toparameters.UseConnectionStringName
or something?Please read the entire post. The text existed as a string correctly. If you do not know, then why post a reply?
-
Please read the entire post. The text existed as a string correctly. If you do not know, then why post a reply?
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?
-
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 readsConfigurationManager.ConnectionString[""].ToString();
Any suggestions on why my variable name is not being written out???was using new code that used the wrong field.....DOH
-
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 readsConfigurationManager.ConnectionString[""].ToString();
Any suggestions on why my variable name is not being written out???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
) ;