06-常量

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 \t world";               // hello     world
string d = @"hello \t world";               // hello \t 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";   // \\server\share\file.txt
string h = @"\\server\share\file.txt";      // \\server\share\file.txt
string i = "one\r\ntwo\r\nthree";   //  \r 换行
string j = @"one       
two
three";                                       //   one\ntwo\nthree

  

4. const

const double pi = 3.14159; // 常量声明

  

参考:

http://www.runoob.com/csharp/csharp-constants.html

猜你喜欢

转载自www.cnblogs.com/alexYuin/p/9067397.html