|
Prev: Why this error message appear
Next: slighty OT: best places to work in the EU for a programmer?
From: Mike Gleason jr Couturier on 8 Jul 2008 09:55 Why do I see a @ preceding strings in code examples? What does the @ do? thanks!
From: Miro on 8 Jul 2008 10:21 Do you mean for 'parameters' in sql statements? Can you post an example of what you see? "Mike Gleason jr Couturier" <nospam(a)invalidhost.com> wrote in message news:urljRJQ4IHA.3500(a)TK2MSFTNGP05.phx.gbl... > Why do I see a @ preceding strings in code examples? > > What does the @ do? > > > thanks! >
From: Rory Becker on 8 Jul 2008 10:40 Hello Mike Gleason jr Couturier, > Why do I see a @ preceding strings in code examples? > > What does the @ do? I believe it is a c# sytax that prevents the compiler otherwise interpreting certain characters as escape codes. for example ------------------------------------------------------------- string SomeString = "\n"; //This produces an enter keystroke string OtherString = @"\n"; //This produces a string containing the backslash and 'n' characters. ------------------------------------------------------------- -- Rory
From: Anthony Jones on 8 Jul 2008 11:17 "Rory Becker" <rorybecker(a)newsgroup.nospam> wrote in message news:3af1034718d0c8caaf282538db6d(a)news.microsoft.com... > Hello Mike Gleason jr Couturier, > > > Why do I see a @ preceding strings in code examples? > > > > What does the @ do? > > I believe it is a c# sytax that prevents the compiler otherwise interpreting > certain characters as escape codes. > > for example > ------------------------------------------------------------- > string SomeString = "\n"; //This produces an enter keystroke > string OtherString = @"\n"; //This produces a string containing the backslash > and 'n' characters. > ------------------------------------------------------------- > Correct and in addition a string preceded with @ can split across lines:- string someSQL = @" SELECT a.Field1, a.Field2 FROM ATable a INNER JOIN BTable b ON b.ID = a.ID WHERE b.Field3 = 15" The down side is that " need to be duplicated as "" e.g.:- string someXML = @"<root thing=""x"" />" -- Anthony Jones - MVP ASP/ASP.NET
From: Jon Skeet [C# MVP] on 8 Jul 2008 13:51 Mike Gleason jr Couturier <nospam(a)invalidhost.com> wrote: > Why do I see a @ preceding strings in code examples? > > What does the @ do? See http://pobox.com/~skeet/csharp/strings.html -- Jon Skeet - <skeet(a)pobox.com> Web site: http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon_skeet C# in Depth: http://csharpindepth.com
|
Next
|
Last
Pages: 1 2 Prev: Why this error message appear Next: slighty OT: best places to work in the EU for a programmer? |