String
is a Collection of characters. Strings are enclosed in double quotes.
Ex:
String
firstName = "Hari Krishna";
String
lastName = "Gurram";
using System; class Program { static void Main(string[] args) { String firstName = "Hari Krishna"; String lastName = "Gurram"; Console.WriteLine("Hello Mr {0} {1}", firstName, lastName); } }
Output
Hello
Mr Hari Krishna Gurram
Escape Sequences
Escape
sequences in programing languages has special meaning, For example, \n prints
string in new line, \t is a tab character etc., Following tables summarizes
some of the escape characters in C#.
Escape Sequence
|
Description
|
\a
|
Bell
alert
|
\b
|
Backspace
|
\f
|
Form
feed
|
\n
|
New
Line
|
\r
|
Carriage
Return
|
\t
|
Horizontal
tab
|
\v
|
Vertical
tab
|
\’
|
Single
Quote
|
\"
|
Double
Quote
|
\\
|
Backslash
|
\?
|
Question
Mark
|
\ooo
|
ASCII
Character in Octal Notation
|
\xhh
|
ASCII
Character in hexadecimal notation
|
\xhhhh
|
Unicode
character in hexadecimal notation
|
Program.cs
using System; class Program { static void Main(string[] args) { String quote = "Life is an \"Open Secret\". \nEverything is avialble, you can't hidden"; Console.WriteLine(quote); } }
Output
Life
is an "Open Secret".
Everything
is avialble, you can't hidden
No comments:
Post a Comment