본문 바로가기
C#

문자열 결합 연산자 StringConcatenate

by JAESEONG LEE- developer 2022. 7. 18.

string result 는 문자열과 함께 사용하는 문자열 결합 연산자 입니다. 

 

int result = 123 + 456; 은 result 값이 579가 됩니다.

string result = "123" + "456"; 은 result 값이 "123456" 이 됩니다.

 

예제 프로그램을 만들어 보겠습니다.

 

 

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
using System;
 
namespace StringConcatenate
{
    class MainApp
    {
        static void Main(string[] args)
        {
            string result = "123" + "456";
            Console.WriteLine(result);
 
            result = "Hello" + " " + "World!";
            Console.WriteLine(result);
        }
    }
}
cs

 

실행 결과입니다. 

'C#' 카테고리의 다른 글

논리 연산자 Logical0perator  (0) 2022.07.19
관계 연산자 Relational0perator  (0) 2022.07.19
증가 연산자와 감소 연산자 IncDec0perator  (0) 2022.07.18
산술 연산자 Arithmatic0perators  (0) 2022.07.18
공용 형식 시스템 CTS  (0) 2022.07.18