473,626 Members | 3,304 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Why does @"""" result in "\""" ??

I posted a related problem today. The problem is this:

string str1 = @"""";

When I execute this code (even in a bare bones application), in the
IDE it returns "\"""

Why? Even in the immediate window it return this. Anywhere where I
attempt to use two apostrophes, it inserts a backslash. Even a
function in one method that saves its string to a file shows that the
backslash is really present because it also gets saved to the file. I
thought maybe just the IDE was having a "display" problem, but that
backslash really is in the string.

I used the repair feature of the VS.NET feature but it didn't help.
This morning I ran an Update on my complete system from Microsoft's
Update Website and I am certain that it has done something to the .NET
framework.

Any help is appreciated.

Thanks,
Johann Blake
Nov 15 '05 #1
2 1554
Johann, those two strings are equal. @"""" =="\""

The @ specifies that the string should be taken literally. The double "'s
indicate that that " shouldn't be considered a string terminator but instead
should be printed. The \" is an escape sequence which again specifies that
the " should not be considered as a string terminator but a ". When I run
the following code I get a single " as I should. In the IDE I do see the
"\"" but that's just how the IDE displays an escaped ". You should not see
the \ in any of the output. If you can reproduce this in a simple program
like I included below feel free to post it so we can check it out.

static void Main(string[] args)
{
string str1 = @"""";
Console.WriteLi ne(str1);
Console.Read();
}

--
Greg Ewing [MVP]
http://www.citidc.com

"Johann Blake" <jb****@closerw orlds.com> wrote in message
news:a6******** *************** ***@posting.goo gle.com...
I posted a related problem today. The problem is this:

string str1 = @"""";

When I execute this code (even in a bare bones application), in the
IDE it returns "\"""

Why? Even in the immediate window it return this. Anywhere where I
attempt to use two apostrophes, it inserts a backslash. Even a
function in one method that saves its string to a file shows that the
backslash is really present because it also gets saved to the file. I
thought maybe just the IDE was having a "display" problem, but that
backslash really is in the string.

I used the repair feature of the VS.NET feature but it didn't help.
This morning I ran an Update on my complete system from Microsoft's
Update Website and I am certain that it has done something to the .NET
framework.

Any help is appreciated.

Thanks,
Johann Blake

Nov 15 '05 #2
Hi Johann,

That's the expected behavior, you see there is two forms of write a string
consisting of a " character:
@"""" or "\""

these are two forms of saying the same thing.

the IDE is always display such expression in the same way, using the escape
sequence.
if you do a Console.Write( ) you will see the same result on both cases.
Hope this help,

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

"Johann Blake" <jb****@closerw orlds.com> wrote in message
news:a6******** *************** ***@posting.goo gle.com...
I posted a related problem today. The problem is this:

string str1 = @"""";

When I execute this code (even in a bare bones application), in the
IDE it returns "\"""

Why? Even in the immediate window it return this. Anywhere where I
attempt to use two apostrophes, it inserts a backslash. Even a
function in one method that saves its string to a file shows that the
backslash is really present because it also gets saved to the file. I
thought maybe just the IDE was having a "display" problem, but that
backslash really is in the string.

I used the repair feature of the VS.NET feature but it didn't help.
This morning I ran an Update on my complete system from Microsoft's
Update Website and I am certain that it has done something to the .NET
framework.

Any help is appreciated.

Thanks,
Johann Blake

Nov 15 '05 #3

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

Similar topics

7
4844
by: Jonas | last post by:
This works fine in Win XP but does not work at all in Win 98. Private WithEvents objIExplorer As InternetExplorer I have to do it like this to get it to work in Win 98 Dim objIExplorer As InternetExplorer But then I cant see when a user exit my objIExplorer and than an error will show up when I try to open a link in the IE window that does not exist... What can I do about this and way does it not work in win 98?
3
29673
by: Jukka K. Korpela | last post by:
I have noticed that the meaning of visibility: collapse has been discussed on different forums, but with no consensus on what it really means. Besides, implementations differ. The specification says: "The 'visibility' property takes the value 'collapse' for row, row group, column, and column group elements. This value causes the entire row or column to be removed from the display, and the space normally taken up by the row or column to...
11
2153
by: Grant Edwards | last post by:
I've read over and over that Python leaves floating point issues up to the underlying platform. This seems to be largely true, but not always. My underlying platform (IA32 Linux) correctly handles 1.0/0.0 and 0.0/0.0 according to the IEEE 754 standard, but Python goes out of its way to do the wrong thing. 1/0 is defined by the standard as +Inf and 0/0 is NaN.
0
2640
by: Dirk Försterling | last post by:
Hi all, a few days ago, I upgraded from PostgreSQL 7.2.1 to 7.4, following the instructions in the INSTALL file, including dump and restore. All this worked fine without any error (message). Since then, I found lots of the following in the postmaster output: 2003-11-29 15:19:54 ERROR: large object 4838779 does not exist 2003-11-29 15:20:11 ERROR: large object 4838779 does not exist
12
2936
by: Frank Hauptlorenz | last post by:
Hello Out there! I have a DB2 V7.2 Database (Fix11) on Win 2000 Professional. It was before a NT 4 based Domain - now it is a Win 2000 Domain. The database server is a domain member. Now sometimes Win 2000 Clients can't connect to the database. They connect over TCP/IP. The db2log says that the function getHostByName failed. It seems to be only on new installed win 2000 Workstations. Already installed WS have NOT this problem.
1
2781
by: Georg Scholz | last post by:
Hello, The class "Control" contains a documented Property "ControlType". So for example, in a form, you can write code like this: Dim c as control set c = me.Controls("textbox1") if c.ControlType = acTextBox then ...
5
14019
by: Genboy | last post by:
My "VIS" Website, which is a C# site created in VS.NET, Framework 1.1, is no longer compiling for me via the command line. As I have done 600 times in the last year and a half, I can compile to VIS.DLL via Visual Studio, with no problems: ------ Rebuild All started: Project: VIS, Configuration: Debug .NET ------ Preparing resources... Updating references...
13
5033
by: Jason Huang | last post by:
Hi, Would someone explain the following coding more detail for me? What's the ( ) for? CurrentText = (TextBox)e.Item.Cells.Controls; Thanks. Jason
16
4971
by: lawrence k | last post by:
I've a file upload script on my site. I just now used it to upload a small text document (10k). Everything worked fine. Then I tried to upload a 5.3 meg Quicktime video. Didn't work. I've set the POST limit in php.ini to 8 megs. What reasons, other than the POST limit, would a large upload fail?
89
6033
by: Cuthbert | last post by:
After compiling the source code with gcc v.4.1.1, I got a warning message: "/tmp/ccixzSIL.o: In function 'main';ex.c: (.text+0x9a): warning: the 'gets' function is dangerous and should not be used." Could anybody tell me why gets() function is dangerous?? Thank you very much. Cuthbert
0
8269
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8711
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8642
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
7203
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5576
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4094
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4206
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2630
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1515
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.