영어 공부/기타

프로그래밍 영어 공부 - C# string (2/n) - string 객체는 생성 후 불변이다 外

manwon 2019. 5. 19. 11:54
반응형

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

 

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

 

6. The + operator concatenates strings.
+ 연산자는 string들을 마치 쇠사슬처럼 연결하는 역할을 한다.

string a = "good " + "morning";

7. This creates a string object that contains "good morning".
위의 코드는 "good morning"이라는 문자열을 포함하는 하나의 string 객체를 생성한다.

8. Strings are immutable--the contents of a string object cannot be changed after the object is created, although the syntax makes it appear as if you can do this.
String들은 변하치 않는 속성을 갖고 있다-- string에 담긴 내용물들은 그 string 객체가 생성된 이후에는 변경되지 않는다. 프로그래밍 상의 문맥이 마치 당신이 그 내용물들을 변경할 수 있는 것처럼 보이게 만들지만 말이다.

9. For example, when you write this code, the compiler actually creates a new string object to hold the new sequence of characters, and that new object is assigned to b. The string "h" is then eligible for garbage collection.
예를 들어서, 당신이 아래와 같은 코드를 작성하면, 사실 컴파일러는 새로운 연속된 문자들을 담기 위한 하나의 새로운 string 객체를 생성한다. 그렇게 생성된 새로운 객체가 참조변수 b에 할당되는 것이다. (원래의) "h" string은 그때 가비지 컬렉션에 의해서 소멸될 대상이 된다.

string b = "h";
b += "ello"

 

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

 

 

반응형