C# uses the string(System.String) type to represent unchangable unicode character list.
To create a simple string we just assign string literal to a string type variable.
using System;
class Sample
{
public static void Main()
{
string str = "java2s.com";
Console.WriteLine(str);
}
}
The output:
java2s.com
The following string literal has escaped sequence.
Escape sequence is for non-inputable character, such new line character.
using System;
class Sample
{
public static void Main()
{
string str = "java2s.com \n java2s.com";
Console.WriteLine(str);
}
}
The output:
java2s.com
java2s.com
Verbatim string
using System;
class Sample
{
public static void Main()
{
string path = @"c:\a\b\c\d.exe";
Console.WriteLine(path);
}
}
The output:
c:\a\b\c\d.exe
java2s.com | Contact Us | Privacy Policy |
Copyright 2009 - 12 Demo Source and Support. All rights reserved. |
All other trademarks are property of their respective owners. |