Добавил:
Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
C-sharp language specification.2004.pdf
Скачиваний:
14
Добавлен:
23.08.2013
Размер:
2.55 Mб
Скачать

C# LANGUAGE SPECIFICATION

1 verbatim-string-literal::

2@" verbatim-string-literal-charactersopt "

3verbatim-string-literal-characters::

4

verbatim-string-literal-character

5

verbatim-string-literal-characters verbatim-string-literal-character

6

verbatim-string-literal-character::

7

single-verbatim-string-literal-character

8

quote-escape-sequence

9

single-verbatim-string-literal-character::

10

Any character except "

11 quote-escape-sequence::

12""

13[Note: A character that follows a backslash character (\) in a regular-string-literal-character shall be one of

14the following characters: ', ", \, 0, a, b, f, n, r, t, u, U, x, v. Otherwise, a compile-time error occurs. end

15note]

16[Example: The example

17

string a = "Happy birthday, Joel";

// Happy birthday, Joel

18

string b = @"Happy birthday, Joel";

// Happy birthday, Joel

19

string c = "hello \t world";

// hello

world

20

string d = @"hello \t world";

// hello \t world

21

string e = "Joe said \"Hello\" to me";

// Joe said "Hello" to me

22

string f = @"Joe said ""Hello"" to me";

// Joe said "Hello" to me

23

string g = "\\\\server\\share\\file.txt";

// \\server\share\file.txt

24

string h = @"\\server\share\file.txt";

// \\server\share\file.txt

25string i = "one\r\ntwo\r\nthree";

26string j = @"one

27two

28three";

29shows a variety of string literals. The last string literal, j, is a verbatim string literal that spans multiple lines.

30The characters between the quotation marks, including white space such as new line characters, are

31preserved verbatim. end example]

32[Note: Since a hexadecimal escape sequence can have a variable number of hex digits, the string literal

33"\x123" contains a single character with hex value 123. To create a string containing the character with hex

34value 12 followed by the character 3, one could write "\x00123" or "\x12" + "3" instead. end note]

35The type of a string-literal is string.

36Each string literal does not necessarily result in a new string instance. When two or more string literals that

37are equivalent according to the string equality operator (§14.9.7), appear in the same assembly, these string

38literals refer to the same string instance. [Example: For instance, the output produced by

39class Test

40{

41

static void Main() {

42

object a = "hello";

43

object b = "hello";

44

System.Console.WriteLine(a == b);

45}

46}

47is True because the two literals refer to the same string instance. end example]

489.4.4.6 The null literal

49null-literal::

50

null

74

Соседние файлы в предмете Электротехника