728x90
[C#] string format, ๋ฌธ์์ด ๋ณด๊ฐ($)์ ์ด์ฉํ ๋ฌธ์์ด ์ถ๋ ฅ๋ฐฉ๋ฒ (tistory.com)
[C#] string format, ๋ฌธ์์ด ๋ณด๊ฐ($)์ ์ด์ฉํ ๋ฌธ์์ด ์ถ๋ ฅ๋ฐฉ๋ฒ
์๋ ํ์ธ์. BlockDMask ์ ๋๋ค. ์ค๋ ๊ณต๋ถํ ๋ด์ฉ์ C#์ string ์ถ๋ ฅ ๋ฐฉ๋ฒ์ ๋๋ค. C#์์๋ string์ ์ถ๋ ฅํ๋ ์ฌ๋ฌ๊ฐ์ง ๋ฐฉ๋ฒ์ด ์กด์ฌํ๋๋ฐ์, ๊ทธ๋ฅ ์ถ๋ ฅํ๋ ๋ฐฉ๋ฒ, format์ ์ด์ฉํ ๋ฐฉ๋ฒ ๊ทธ๋ฆฌ๊ณ ๋ฌธ์์ด
blockdmask.tistory.com
1.
using System;
using System.Collections.Generic;
using System.Text;
using static System.Console;
namespace Hello
{
class MainApp
{
static void Main(string[] args)
{
byte a = 240;
int aa = 2424;
string aaa = "you";
int num = 999;
string str1 = string.Format("Example2 : {0}, {1}, {2}", "BlockDMask", 3434, num);
string str2 = $"a={a} {aa} {aaa}";
WriteLine(str1);
WriteLine(str2);
}
}
}
์ถ๋ ฅ
Example2 : BlockDMask, 3434, 999
a=240 2424 you
2.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static System.Console;
namespace Hello
{
class MainApp
{
static void Main(string[] args)
{
byte a = 240;
int aa = 2424;
string aaa = "you";
WriteLine($"a={a} {aa} {aaa}");
WriteLine("a={0} {1} {2}", a,aa,aaa);
WriteLine("a={0} {1} {2}", 240, 2424, "you");
}
}
}
์ถ๋ ฅ
a=240 2424 you
a=240 2424 you
a=240 2424 you
๋๋ ์ :
C#์์๋ $ ๊ธฐํธ๋ฅผ ์ฌ์ฉํ๋ ๊ฒ์ด ๊ต์ฅํ ํธ๋ฆฌํ ๊ฒ ๊ฐ๋ค.
$ํ์ํ ๋ค์ {} ๊ดํธ ์์ ๋ณ์๋ฅผ ๋ฃ์ด๋ ๋๊ณ ์ง์ ์ ์ธ ๊ฐ์ ๋ฃ์ด๋ ์ถ๋ ฅ์ด ๋๊ณ
WriteLine๊ณผ์ ํธ์๋ ์ข๊ณ ,
๊ทธ ์์ฒด๋ก string ๋ณ์์ ๋ด์ ์๋ ์๋ค.
728x90
'C# > C#' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
ํด๋์ค๋ฅผ ๋ฐฐ์ด๋ก ์ ์ธํ๊ธฐ (0) | 2022.02.24 |
---|---|
ํ๋, ๋ฉค๋ฒ, ์ง์ญ๋ณ์, ์ ์ ํ๋, ์ ์ ๋ฉ์๋ ๊ฐ๋ ์ ๋ฆฌ (0) | 2022.02.14 |
[C# ์ฝ์] 5x5 ๋๊ทธ๋ผ๋ฏธํ ์ถ๋ ฅ (0) | 2022.02.02 |
C# ๊ฐ๋ณ๋ฐฐ์ด (0) | 2022.01.22 |
C#(5) : ๊ฐํ์์ ๋ฉ๋ชจ๋ฆฌ ๊ตฌ์กฐ ๋ฐ ์ฒ๋ฆฌ vs ๋ํผ๋ฐ์ค์ ๋ฉ๋ชจ๋ฆฌ ๊ตฌ์กฐ ๋ฐ ์ฒ๋ฆฌ (0) | 2022.01.22 |