Overload
Console.Write()와 Console.WriteLine() 메소드는 하나의 변수나 값을 출력할 때는 어떤 자료형이라도 출력가능.
이유로 해당 메소드가 여러 가지 자료형에 대해 overload되어 있기 때문.
코드
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace A007_ConsoleWriteLine
{
class Program
{
static void Main(string[] args)
{
bool b = true;
char c = 'A';
decimal d = 1.234m;
double e = 1.23456789;
float f = 1.23456789f;
int i = 1234;
string s = "Hello";
Console.WriteLine(b);
Console.WriteLine(c);
Console.WriteLine(d);
Console.WriteLine(e);
Console.WriteLine(f);
Console.WriteLine(i);
Console.WriteLine(s);
}
}
}
코드 실행
반응형
'C# > C# 입문' 카테고리의 다른 글
9. 두 변수를 출력하는 방법 (0) | 2024.09.02 |
---|---|
8. Console.WriteLine 메소드로 여러 개의 값을 출력 (0) | 2024.09.02 |
6. 대입연산자와 대입문 (0) | 2024.09.02 |
5. 문자와 문자열 (0) | 2024.09.01 |
var 형 (0) | 2024.09.01 |