영어 공부/기타

프로그래밍 영어 공부 - C# string (3/n) - string과 [] 연산자, quated

manwon 2019. 5. 23. 09:00
반응형

[알림] 본 페이지는 microsoft.com에 나온 C# 영문서를 본인이 우리말로 번역한 것입니다. 이해를 위해서 의역을 한 곳도 있습니다. 잘못된 해석은 댓글로 알려주시면 감사하겠습니다.

 

string C# Reference [원문 링크]
string C# 레퍼런스

 

10. The [] operator can be used for readonly access to individual characters of a string:
[] 연산자는 하나의 string을 구성하고 있는 각각의 문자들에게 읽기 전용으로 접근할 때 사용될 수 있다.

string str = "test";
char x=str[2]; // x='s';

11. In similar fashion, the [] operator can also be used for iterating over each character in a string:
비슷한 방법으로, [] 연산자는 하나의 string 안에 존재하는 문자 하나 하나에 대해서 반복적인 작업을 할 때도 사용된다.

string str = "test";
for(int i=0; i<str.Length; i++)
{
    Console.Write(str[i] + " ");
}
// Output: t e s t 

12. String literals are of type string and can be written in two forms, quoted and @-quoted. Quoted string literals are enclosed in double quotation marks("):
string 리터럴즈는 string 유형의 것이며, quated 혹은 @-quoted의 형태로 쓰여질 수 있다. Quoted 형태의 string 리터럴즈는 큰따옴표(")로 묶여 있다 .

"good morning" // a string literal

13. String literals can contain any character literal. Escape sequences are included. The following example uses escape sequence \\ for backslash, \u0066 for the letter f, and \n for newline.
string 리터럴즈는 어떠한 character 리터럴이라도 포함할 수 있다. 이스케이프 시퀀스도 포함된다. 다음 예제에서 이스케이프 시퀀스인 \\는 백슬래시로, \u0066은 문자 f로, \n은 줄바꿈으로 사용된다.

string a = "\\\u0066\n";
Console.Writeline(a); // 실제 출력은 \f(줄바꿈)

 

to be continued...
다음 포스팅에 계속...

반응형