Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 Development Tools
 ASP.NET
 adding " at the begining and the end of a string

Author  Topic 

rtutus
Aged Yak Warrior

522 Posts

Posted - 2007-02-26 : 10:07:23
how to add a " at the begining and the end of a string variable

Let s say I have a string variable called targ

if the value of targ is: d:\Program Files\Common Files

I need to produce this in code:

"d:\Program Files\Common Files"

So I want a string variable with quotations appended to it

I tried this but nio luck:

string targ = "" + targ + "";
Any help pls?

Thanks

jsmith8858
Dr. Cross Join

7423 Posts

Posted - 2007-02-26 : 10:30:17
In C#, you can escape things with the \ character:

string targ = "\"" + targ + "\"";

Thats a pretty crucial part of C# to understand, so definitely read up on escaping strings in C# and practice it to get the hang of it and the different options that you have.




- Jeff
http://weblogs.sqlteam.com/JeffS
Go to Top of Page

rtutus
Aged Yak Warrior

522 Posts

Posted - 2007-03-08 : 21:15:48
Thank you very much
Go to Top of Page
   

- Advertisement -