언어/[C#]
[C#] 타입캐스트 TypeCasting (Convert class)
조랩
2023. 2. 25. 20:43
using System;
namespace MyFirstProgram
{
internal class Program
{
static void Main(string[] args) // main method
{
double x = 3.14;
int x_2 = Convert.ToInt32(x);
Console.WriteLine(x.GetType());
Console.WriteLine(x_2.GetType());
double d = Convert.ToDouble(x_2) + 0.14;
Console.WriteLine(d.GetType());
// int e = 321;
double e = 312.123;
String f = Convert.ToString(e);
Console.WriteLine(f.GetType());
String g = "$";
char h = Convert.ToChar(g);
Console.WriteLine(h);
Console.WriteLine(h.GetType());
String i = "true";
bool j = Convert.ToBoolean(i);
Console.WriteLine(j);
Console.WriteLine(j.GetType());
}
}
}
728x90