Link to home
Create AccountLog in
Avatar of chokka
chokkaFlag for United States of America

asked on

Declaring string variables in C#

I have a line of string variable which comes as like this

 "abc","","def", ""

all the values has double quotes

string strline = "  "abc","","def", ""   "

I am sure, i need to add + sign to get the double quotes. I am just looking for best way to fix this. This is a very lengthy line.
Avatar of Julian Hansen
Julian Hansen
Flag of South Africa image

You can escape the internal double quotes with a backslashes or simply create the string like so
string strline = @" "abc","","def","" ";

Open in new window

Avatar of chokka

ASKER

I tested that string, it doesn't compile. I tested exact your line in the Visual Studio Environment.
ASKER CERTIFIED SOLUTION
Avatar of AndyAinscow
AndyAinscow
Flag of Switzerland image

Link to home
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
See answer
Avatar of chokka

ASKER

Thank you andy, it works
Avatar of chokka

ASKER

Thanks
You need to double quote your quotes.

string strline = @" ""abc"","""",""def"","""" ";