473,386 Members | 1,702 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,386 software developers and data experts.

How can I get this statement to work: string strData = '\xB';

How can I get this statement to work:
string strData = '\xB';

I get the error: Cannot implicitly convert type 'char' to 'string'.
Can anyone help?

PT
Nov 16 '05 #1
3 2266
Max Adams <ru************@hotmail.com> wrote:
How can I get this statement to work:
string strData = '\xB';

I get the error: Cannot implicitly convert type 'char' to 'string'.
Can anyone help?


Sure:

string strData = "\xB";

'' is used for specifying a single character.
"" is used for specifying a string.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Nov 16 '05 #2
How can I get this statement to work:
string strData = '\xB';

I get the error: Cannot implicitly convert type 'char' to 'string'.
Can anyone help?


Sure:

string strData = "\xB";

'' is used for specifying a single character.
"" is used for specifying a string.

And that will give me the code for the ASCII character <VT>??

Nov 16 '05 #3
Max Adams <ru************@hotmail.com> wrote:
How can I get this statement to work:
string strData = '\xB';

I get the error: Cannot implicitly convert type 'char' to 'string'.
Can anyone help?


Sure:

string strData = "\xB";

'' is used for specifying a single character.
"" is used for specifying a string.

And that will give me the code for the ASCII character <VT>??


Yup - although using "\v" would be simpler :)

On a related point though, when you *do* need to specify a Unicode
character in that kind of way, I'd suggest using \u instead - it's less
error prone. For instance, using your example:

"hello\xBworld" gives you what you want, but:

"hello\xBBob" doesn't, because the second B is treated as part of the
hex string too. Using

"hello\u000BBob" is fine though.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Nov 16 '05 #4

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

Similar topics

8
by: Beznas | last post by:
Hi All; I'm trying to create an ASP function called CleanX that removes the punctuation and some characters like (*&^%$#@!<>?"}|{..) from a text string I came up with this but It...
9
by: Christopher Brandsdal | last post by:
Just a little question... How do I split 12345678 into 12 34 56 78??????? Christopher Brandsdal
3
by: soni29 | last post by:
hi, how can i remove a string from an existing string in javascript. i have a textbox in a form and want to make sure that when the user clicks a button that certain words are moved, like all...
7
by: VMI | last post by:
If I have the string "Héllo", how can I replace char (é) with an 'e'? I cannot use the String.Replace() fuction. It has to be by replacing one char with another. Thanks.
3
by: vbMark | last post by:
A long, long time ago when I programmed in basic, I could have following lines, for example: Data "dog,1,yes,brown" Data "cat,3,yes,white" Data "horse,1,no,brown" Data "pig,7,no,pink" Data...
1
by: Finaly | last post by:
I'm trying to upload some text to a basic CMS but am having problems whenever a "double quote" is included. I've run a replace function which elminates 'single qoutes' which works fine but I can't...
4
by: Susan Rice | last post by:
I'm new to using CString. Why won't the following compile? I'm using Microsoft Visual C++ 6.0 Line 37 which it complains about is the function: 37 CString ConvertFile(char *szFileName) I...
8
by: asenthil | last post by:
Hai, i'm having a string in a specific field of a database... now i want to retrive that string from the database and i have to write that string into a xml file.... retriving is not a...
1
lifeisgreat20009
by: lifeisgreat20009 | last post by:
This is what i am getting on running the program......... C:\PROGRA~1\Java\JDK15~1.0\bin>javac Editor.java Note: Editor.java uses or overrides a deprecated API. Note: Recompile with...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.