04 문자와 문자열
개념
1. 문자(char)
1-1. C#에서 문자는 유니코드(Unicode) 문자 1개를 말한다.
1-2. 단일 인용 부호로 표기 합니다. example) char variable = 'c';
1-3. 한글, 한자등의 전각 문자도 문자형 변수에 대입할수 있다. example) char hanguleGa='가';
2. 문자열(string)
2-1. 복수의 문자열을 말합니다.
2-2 이중 인용 부호로 표기 합니다. example) string variable = "interesting string";
2-3 문자열의 결합은 + 로 할수 있습니다. (한쪽에 수치형int등으로 되어 있어도 문자로 적용합니다. )
example) string test = 3 + "월" + "입니다." // 결과 : 3월입니다.
소스코드 : CharToString.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace _04charTostring
{
class CharToString
{
static void Main()
{
char chVariable = '잔';
int nVariable = 10;
string strVariable = "Coffee";
string strResult = strVariable + nVariable + chVariable;
Console.WriteLine(strResult);
}
}
}
결과 :