Monday, 14 January 2013 13:56

how to use verbatim string

Written by 
Rate this item
(0 votes)

verbatim string is a string which is interpreted
by the compiler exactly as it is written, meaning
that even if the string spans multiple lines
or keeps escape characters,etc.

these are not interpreted by compiler and they are kept
with the output-


verbatim string starts with an @ sign character
followed by the string in quotation marks -

string csharp = @"Hello\tWorld"; // produces "Hello\tWorld"
string csharpExample = @"c:\Csharp\sample.txt";
// produces c:\Csharp\sample.txt

always use verbatim string to defin connection
string or query string -

string query = @"INSERT INTO t_Student VALUES
('" + studentObj.FirstName + "','" + studentObj.MiddleName + "','"
+ studentObj.LastName + "','" + studentObj.Address + "','" +
studentObj.MobileNumber + "','" + studentObj.DateOfBirth + "')";

Read 4121 times
Super User

Email This email address is being protected from spambots. You need JavaScript enabled to view it.

Latest discussions

  • No posts to display.