Console Programming/C# Console
6일차 문자열 표현식들
폰타인
2019. 9. 25. 10:54
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Syntax15
{
class Program
{
static void Main(string[] args)
{
//문자열 표현식
string name = "홍길동";
int level = 12;
float damage = 5.6f;
//이름: 홍길동, 레벨: 12, 공격력: 5.6 을 출력하려면
Console.WriteLine("이름: " + name + ", 레벨: " + level + ", 공격력: " + damage);//결합연산자를 사용
Console.WriteLine("이름: {0}, 레벨: {1}, 공격력: {2}",name, level, damage); //string format
Console.WriteLine($"이름: {name}, 레벨: {level}, 공격력: {damage}"); //string interpolation
}
}
}
http://colorscripter.com/info#e" target="_blank" style="color:#e5e5e5text-decoration:none">Colored by Color Scripter
|
어떤 방법을 사용해도 출력 결과는 같게 나타난다.
