Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old May 29th, 2007, 10:31 AM   #1
teishu
Programmer
 
Join Date: May 2006
Posts: 51
Rep Power: 3 teishu is on a distinguished road
Small C# Problem - quotation marks in string

Hi, im having trouble with quotation marks in a string.. here is the code that is bugging me..

html.WriteLine("<img src=""images//" & file & """ />");

i need it to output the line as follows:

<img src="images/imagename.jpg" />

the imagename.jpg is define in the file string.

the errors are as follows:

Error    1    ) expected    C:\Documents and Settings\Jason\My Documents\Visual Studio 2005\Projects\Project01\Project01\Form1.cs    63    43    Project01

Error    2    ; expected    C:\Documents and Settings\Jason\My Documents\Visual Studio 2005\Projects\Project01\Project01\Form1.cs    63    65    Project01

Error    3    ; expected    C:\Documents and Settings\Jason\My Documents\Visual Studio 2005\Projects\Project01\Project01\Form1.cs    63    70    Project01

Error    4    Invalid expression term ')'    C:\Documents and Settings\Jason\My Documents\Visual Studio 2005\Projects\Project01\Project01\Form1.cs    63    70    Project01

thanks in advance...
teishu is offline   Reply With Quote
Old May 29th, 2007, 10:36 AM   #2
Kezzer
Newbie
 
Join Date: Mar 2007
Location: England
Posts: 15
Rep Power: 0 Kezzer is on a distinguished road
Send a message via Skype™ to Kezzer
Use the escape sequence \" to display the quotation mark otherwise it will exit the string literal in the function argument.

html.WriteLine("<img src=\"images//\" & file & "\" />");

Or something along those lines.
Kezzer is offline   Reply With Quote
Old May 29th, 2007, 11:04 AM   #3
teishu
Programmer
 
Join Date: May 2006
Posts: 51
Rep Power: 3 teishu is on a distinguished road
Quote:
Originally Posted by Kezzer View Post
Use the escape sequence \" to display the quotation mark otherwise it will exit the string literal in the function argument.

html.WriteLine("<img src=\"images//\" & file & "\" />");

Or something along those lines.
that seems to give me even more errors
__________________
AMD Athlon X2 4200+ -- Asus V3-M2V890 -- 2GB Kingston -- Vista Ultimate 32bit + Ubuntu 8.04
Intel C2D T5870 2.0GHZ -- Vostro 1510 -- 2048MB -- Windows XP SP2

ASCII stupid question, get a stupid ANSI !
teishu is offline   Reply With Quote
Old May 29th, 2007, 11:07 AM   #4
ReggaetonKing
Sexy Programmer
 
ReggaetonKing's Avatar
 
Join Date: Nov 2005
Location: New Jersey
Posts: 891
Rep Power: 3 ReggaetonKing is on a distinguished road
Send a message via AIM to ReggaetonKing
Try this:
html.WriteLine("<img src=\"images//\"" + file + "\" />");
__________________
I would love to change the world, but they won't give me the source code!
ReggaetonKing is offline   Reply With Quote
Old May 29th, 2007, 11:14 AM   #5
Kezzer
Newbie
 
Join Date: Mar 2007
Location: England
Posts: 15
Rep Power: 0 Kezzer is on a distinguished road
Send a message via Skype™ to Kezzer
Ah, one quotation mark off, didn't spot that *headache looms*
Kezzer is offline   Reply With Quote
Old May 29th, 2007, 11:20 AM   #6
teishu
Programmer
 
Join Date: May 2006
Posts: 51
Rep Power: 3 teishu is on a distinguished road
Quote:
Originally Posted by reggaeton_king View Post
Try this:
html.WriteLine("<img src=\"images//\"" + file + "\" />");
cheers m8, seems to do the trick..
there were so many question marks i couldn't get my head round them all lol! :banana:
__________________
AMD Athlon X2 4200+ -- Asus V3-M2V890 -- 2GB Kingston -- Vista Ultimate 32bit + Ubuntu 8.04
Intel C2D T5870 2.0GHZ -- Vostro 1510 -- 2048MB -- Windows XP SP2

ASCII stupid question, get a stupid ANSI !
teishu is offline   Reply With Quote
Old May 30th, 2007, 7:52 AM   #7
pegasus001
Hobbyist Programmer
 
pegasus001's Avatar
 
Join Date: Nov 2006
Location: 163H
Posts: 213
Rep Power: 2 pegasus001 is on a distinguished road
You can use the @ before the strign, if i am not mistaken like :
@"<img src=""images//" & file & "" />"
This tells the compiler to take the string as is, a preformatted string.
__________________
You never test the depth of a river with both feet.
The believer is happy. The doubter is wise.
Free speech carries with it some freedom to listen.
The next generation will always surpass the previous one. It`s one of the never ending cycles of life.
pegasus001 is offline   Reply With Quote
Old May 30th, 2007, 8:16 AM   #8
teishu
Programmer
 
Join Date: May 2006
Posts: 51
Rep Power: 3 teishu is on a distinguished road
Quote:
Originally Posted by pegasus001 View Post
You can use the @ before the strign, if i am not mistaken like :
@"<img src=""images//" & file & "" />"
This tells the compiler to take the string as is, a preformatted string.
ah cool, ill have to remember that. will come in handy.
thanks
__________________
AMD Athlon X2 4200+ -- Asus V3-M2V890 -- 2GB Kingston -- Vista Ultimate 32bit + Ubuntu 8.04
Intel C2D T5870 2.0GHZ -- Vostro 1510 -- 2048MB -- Windows XP SP2

ASCII stupid question, get a stupid ANSI !
teishu is offline   Reply With Quote
Old Jun 1st, 2007, 6:27 AM   #9
Kezzer
Newbie
 
Join Date: Mar 2007
Location: England
Posts: 15
Rep Power: 0 Kezzer is on a distinguished road
Send a message via Skype™ to Kezzer
Quote:
Originally Posted by pegasus001 View Post
You can use the @ before the strign, if i am not mistaken like :
@"<img src=""images//" & file & "" />"
This tells the compiler to take the string as is, a preformatted string.
Odd how I never knew that. Handy tip though, I'm assuming the @ symbol acts as a compiler preprocessor and formats the string for you.

Cheers for the tip, pegasus.
Kezzer is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
An Attempt at a DBMS grimpirate PHP 8 Apr 17th, 2007 1:01 PM
Function Parameters grimpirate PHP 10 Mar 14th, 2007 6:55 PM
C# corruption!!! Kilo C++ 32 May 21st, 2006 8:44 PM
Array issues :( Alo Tsum Java 10 Nov 26th, 2005 5:45 PM
replace space with ' * ' TecBrain C++ 15 Apr 13th, 2005 12:32 PM




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 8:30 AM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC