1. 进制
前缀:0x 或 0X 表示十六进制,0 表示八进制,没有前缀则表示十进制。
后缀:可以是 U 或 L 的组合,其中,U 和 L 分别表示 unsigned 和 long。后缀可以是大写或者小写。
2. 科学记数法
e
3. 字符串
转义字符同C++
@的用法:
string a = "hello, world"; // hello, world string b = @"hello, world"; // hello, world string c = "hello world"; // hello world string d = @"hello world"; // hello world string e = "Joe said "Hello" to me"; // Joe said "Hello" to me string f = @"Joe said ""Hello"" to me"; // Joe said "Hello" to me string g = "\\server\share\file.txt"; // \serversharefile.txt string h = @"\serversharefile.txt"; // \serversharefile.txt string i = "one two three"; // 换行 string j = @"one two three"; // one two three
4. const
const double pi = 3.14159; // 常量声明
参考:
http://www.runoob.com/csharp/csharp-constants.html