String question
-
What is the technical difference between defining a string this way:
string s = "this is my string";
and this way?string s = @"this is my string";
-
What is the technical difference between defining a string this way:
string s = "this is my string";
and this way?string s = @"this is my string";
-
What is the technical difference between defining a string this way:
string s = "this is my string";
and this way?string s = @"this is my string";
Mike Ellison wrote: What is the technical difference between defining a string this way: string s = "this is my string"; and this way? string s = @"this is my string"; Well the first would try to escape certain characters followed by a slash string s = "this is a line \n with a newline embedded"; string s = @"this is a line \n with a slash n embedded"; The @ sign tells the compiler "this is a literal string, don't escape the characters after the slash". Hope this helps, Nathan --------------------------- Hmmm... what's a signature?
-
using the @ means you don't have to escape the \ character eg. string s = "\\\\Server\\folder"; it the same as string s = @"\\Server\folder"; Grant @ Loki
sheesh, you beat my by two minutes.... hehe... that's what I get for reading down the page first :) --------------------------- Hmmm... what's a signature?
-
Mike Ellison wrote: What is the technical difference between defining a string this way: string s = "this is my string"; and this way? string s = @"this is my string"; Well the first would try to escape certain characters followed by a slash string s = "this is a line \n with a newline embedded"; string s = @"this is a line \n with a slash n embedded"; The @ sign tells the compiler "this is a literal string, don't escape the characters after the slash". Hope this helps, Nathan --------------------------- Hmmm... what's a signature?
Nathan Blomquist wrote: string s = @"this is a line \n with a slash n embedded"; And also: string s = @"this is a string with two lines";
Help me dominate the world - click this link and my army will grow
-
What is the technical difference between defining a string this way:
string s = "this is my string";
and this way?string s = @"this is my string";
Thanks!
-
What is the technical difference between defining a string this way:
string s = "this is my string";
and this way?string s = @"this is my string";
Mike, It looks like everyone has answered you question here. I just wanted to add that strings that are defined with the "@" sign are called verbatim strings. -Nick Parker
-
Mike, It looks like everyone has answered you question here. I just wanted to add that strings that are defined with the "@" sign are called verbatim strings. -Nick Parker
Thanks, Nick. Every bit of useful information helps!