영어 공부/기타

프로그래밍 영어 공부 - C# string (1/n) - 닷넷에서 string은 String의 별칭이다 外

manwon 2019. 5. 18. 10:27
반응형

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

 

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

 

1. The string type represents a sequence of zero or more Unicode characters.
string 타입은 0개 이상의 유니코드 문자들이 연속적이고 순차적으로 놓여진 것을 말한다.

2. string is an alias for String in .NET.
닷넷에서 string은 String의 별칭이다.

3. Although string is a reference type, the equality operators (== and !=) are defined to compare the values of string objects, not references.
string은 참조 타입이지만 ==, != 같은 이퀄 연산자와 함께 쓰일 때는 같은 곳을 참조하는가를 따지는 게 아니라, string 객체의 value값이 같은가를 따지도록 정의되어 있다.

4. This makes testing for string equality more intuitive. For example.
그런 정의로 인해, 문자열이 서로 동일한지 여부를 따지는 테스트를 보다 쉽게 할 수 있게 되었다. 다음 예를 보자. 


string a="hello";
string b="h";
//Append to contents of 'b'
b+="ello"
Console.WriteLine(a==b);
Console.WriteLine((object)a==(object)b);


5. This displays "True" and then "False" because the content of the strings are equivalent, but a and b do not refer to the same string instance.
위 코드는 "True"와 "False"를 출력한다. 왜냐면 string들의 내용이 서로 동일하기 때문이다. 하지만 참조변수 a와 b는 동일한 string 인스턴스를 참조하지 않는다. (참조하지 않는다 == 가리키지 않는다)  

 

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

반응형