KO CSharp Keyword decimal - LIHACHTETAN/ClassicUO-Bad-Newbie-CSharp-Scripts-IDE GitHub Wiki
ะฃะบัะฐัะฝััะบะฐ ยท ะ ัััะบะธะน ยท English ยท Deutsch ยท Franรงais ยท Italiano ยท Espaรฑol ยท ็น้ซไธญๆ ยท ๆฅๆฌ่ช ยท ํ๊ตญ์ด
C#: decimal
ํธ๋๋ถ C# ยท ์ค์ฉ ๊ฐ์ด๋
์์ ํํ์ด ์ค์ํ ๊ณ์ฐ์ ์ํ ์์์ ๋๋ค.
๊ฐ๋จํ ์์ (Example.cs)
์ด ์์ ๋ฅผ Example.cs๋ก ๋ฐ๋ก ์ ์ฅํ๊ณ ์ด ํ์ด์ง์ ๋ค๋ฅธ ์์ ์ ๋
๋ฆฝ์ ์ผ๋ก ์คํํ์ธ์.
Example.cs:
// PROJECT-EXAMPLE
decimal amount = 12.5M;
var result = amount + 2;
System.Console.WriteLine(result.ToString(System.Globalization.CultureInfo.InvariantCulture));
๊ฒฐ๊ณผ:
14.5
ํต์ฌ๋ก
decimal value = 12.5M;
๋ณ์์ ์ ํ์ ๋ฐ๋ผ ์ฐ์ ์ ๋ฒ์์ ๊ท์น์ด ๊ฒฐ์ ๋ฉ๋๋ค. ์ ์์ ์ค๋ฒํ๋ก๋ฅผ ํ์ธํ๋ ค๋ฉด selected๋ฅผ ์ฌ์ฉํ์ธ์. ํ ์คํธ ๋ณํ โ TryParse.
์์ 1: ๊ธฐ๋ณธ ํํ
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using System.IO;
using System.Runtime.InteropServices;
using System.Runtime.CompilerServices;
public static class Program
{
public static async Task Main(string[] args)
{
decimal first = 12.5M;
decimal second = 2;
Console.WriteLine(first + second);
}
}
์ 2: ๋ ๋ค๋ฅธ ์ค์ ํ์
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using System.IO;
using System.Runtime.InteropServices;
using System.Runtime.CompilerServices;
public static class Program
{
public static async Task Main(string[] args)
{
decimal[] values = [12.5M, 2, 3];
foreach (decimal value in values) Console.WriteLine(value);
Console.WriteLine(decimal.MaxValue);
}
}
๊ณต์ ์ถ์ฒ: Microsoft ํ์ต.