473,406 Members | 2,336 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

How to put this " symbol into a string?

hi all

i would like to include the double quote " symbol into the string. How can
i do it?

cheers

Nov 21 '05 #1
8 3147
There are a lot of ways of doing so... But I personally prefer the
following:

Dim strMyString as string = "ABCDEFG~HIJK"
strMyString.Replace("~", chr(34))

"Roy T" <Ro**@discussions.microsoft.com> wrote in message
news:7C**********************************@microsof t.com...
hi all

i would like to include the double quote " symbol into the string. How
can
i do it?

cheers

Nov 21 '05 #2
Just put two " into the string: myString = "Hello ""World"""

would be: Hello "World"

"Roy T" <Ro**@discussions.microsoft.com> wrote in message
news:7C**********************************@microsof t.com...
hi all

i would like to include the double quote " symbol into the string. How can
i do it?

cheers
Nov 21 '05 #3
Just escape it with another " char (two consequtive " chars)

"Roy T" <Ro**@discussions.microsoft.com> wrote in message
news:7C**********************************@microsof t.com...
hi all

i would like to include the double quote " symbol into the string. How can
i do it?

cheers
Nov 21 '05 #4
* "=?Utf-8?B?Um95IFQ=?=" <Ro**@discussions.microsoft.com> scripsit:
i would like to include the double quote " symbol into the string. How can
i do it?


\\\
Dim s As String = _
"He said: ""Hello World!"""
Dim t As String = _
"He said: " & ControlChars.Quote & "Hello World!" & ControlChars.Quote
///

Notice that there is no performance loss in using the string
concatenation operator in the 2nd sample, the string is concatenated by
the compiler and stored as a single constant in the assembly.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>
Nov 21 '05 #5
FYI, the ControlChars.Quote method is my favorite.
It is very clear what you are doing and makes code very readable and
maintainable.
Much more so than "" """", which can be confused with '', '''' (single quotes)
IMHO, I would recommend this as a "best practice".

Gerald

"Herfried K. Wagner [MVP]" <hi***************@gmx.at> wrote in message
news:Oy**************@TK2MSFTNGP10.phx.gbl...
* "=?Utf-8?B?Um95IFQ=?=" <Ro**@discussions.microsoft.com> scripsit:
i would like to include the double quote " symbol into the string. How can
i do it?


\\\
Dim s As String = _
"He said: ""Hello World!"""
Dim t As String = _
"He said: " & ControlChars.Quote & "Hello World!" & ControlChars.Quote
///

Notice that there is no performance loss in using the string
concatenation operator in the 2nd sample, the string is concatenated by
the compiler and stored as a single constant in the assembly.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>

Nov 21 '05 #6
* "Cablewizard" <Ca*********@Yahoo.com> scripsit:
FYI, the ControlChars.Quote method is my favorite.
It is very clear what you are doing and makes code very readable and
maintainable.
Much more so than "" """", which can be confused with '', '''' (single quotes)
IMHO, I would recommend this as a "best practice".


I always use the double quotes inside the string literal. It's IMO just
a matter of personal preference.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>
Nov 21 '05 #7

"Cablewizard" <Ca*********@Yahoo.com> wrote in message
news:ug**************@TK2MSFTNGP12.phx.gbl...
FYI, the ControlChars.Quote method is my favorite.
It is very clear what you are doing and makes code very readable and
maintainable.
Much more so than "" """", which can be confused with '', '''' (single quotes) IMHO, I would recommend this as a "best practice".


I wouldn't. I find the string concatenation much harder to read.
Nov 21 '05 #8
I suppose it is personal preference.
Personally, I like to see the quotes stand out as in the concatenation.
Really helps me visualize exactly what is going on, especially when constructing
SQL statements.
Either way works just great.

Gerald

"Cablewizard" <Ca*********@Yahoo.com> wrote in message
news:ug**************@TK2MSFTNGP12.phx.gbl...
FYI, the ControlChars.Quote method is my favorite.
It is very clear what you are doing and makes code very readable and
maintainable.
Much more so than "" """", which can be confused with '', '''' (single quotes)
IMHO, I would recommend this as a "best practice".

Gerald

"Herfried K. Wagner [MVP]" <hi***************@gmx.at> wrote in message
news:Oy**************@TK2MSFTNGP10.phx.gbl...
* "=?Utf-8?B?Um95IFQ=?=" <Ro**@discussions.microsoft.com> scripsit:
i would like to include the double quote " symbol into the string. How can i do it?


\\\
Dim s As String = _
"He said: ""Hello World!"""
Dim t As String = _
"He said: " & ControlChars.Quote & "Hello World!" & ControlChars.Quote
///

Notice that there is no performance loss in using the string
concatenation operator in the 2nd sample, the string is concatenated by
the compiler and stored as a single constant in the assembly.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>


Nov 21 '05 #9

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

68
by: Marco Bubke | last post by:
Hi I have read some mail on the dev mailing list about PEP 318 and find the new Syntax really ugly. def foo(x, y): pass I call this foo(1, 2), this isn't really intuitive to me! Also I...
1
by: yanwan | last post by:
I met this problem in executing a c++ project in visual studio. Does anyone have suggestions to resolve "error lnk 2001"? --------------------Configuration: reconstruction - Win32...
4
by: ±èµ¿±Õ | last post by:
Tell me why the symbol "_" use in the Library? For example, char *_itoa( int value, char *string, int radix ); But We use function "itoa(value,string,radix) "only. I want to know the...
5
by: brckcc | last post by:
Sometimes when I view my string variables in the watch window, it shows an @ symbol preceding the value. Other times, I don't see the @ symbol. What does this mean?
3
by: Kenneth Kahl | last post by:
Hello, I would like to call a C++ programm out of Java with help of JNI. By the followed command I created a "shared library": g++ -shared -o libcalculate.so rechner.cpp When I create an...
15
by: Bjorn Jensen | last post by:
Hi! An beginner question: Pleas help me with this (-: Error (the arrow points on the s in sqrt) ===== tal.java:6: cannot find symbol symbol : method sqrt(int) location: class tal...
3
by: hsmsites | last post by:
Anyone know how I can remove this symbol from a string. I'm using vi and do not know how to refer to this symbol in my script. TIA
2
by: Phil Davidson | last post by:
/* (Posted to microsoft.public.dotnet.languages.vc) In C++/CLI under Visual Studio 2005, creating an "enum class" member called "Equals" can cause compiler error C1060 (out of memory) and C1063...
4
by: jk2l | last post by:
Error 10 error LNK2019: unresolved external symbol __imp__glBindTexture@8 referenced in function "public: void __thiscall GLTexture::Use(void)" (?Use@GLTexture@@QAEXXZ) GLTexture.obj Error 11 error...
11
by: hamiltongreg | last post by:
I am new to Java and am having problems getting my program to compile correctly. My assignment is as follows; Choose a product that lends itself to an inventory (for example, products at your...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.