표준 출력
Console.WriteLine()
- c# 프로그래밍의 가장 기본 출력방법
- System 네임스페이스의 Console 클래스의 WriteLine() 메서드
System.Console.WrireLine();
Console.Write()
- Console.WroteLine()은 개행(\n)이 되지만 Console.Write()는 개행이 되지 않는다.
Console.WriteLine("hello, world");
Console.Write("hello, ");
Console.Write("world");
using static System.Console;
- using System을 사용하면 System이라는 네임스페이스를 선언하지 않아도 되지만 Console이라는 메서드도 사용하기 싫을 때는
using static System.Console;
선언하여 사용할 수 있다.
using static System.Console;
WriteLine("hello, world\n");
변수값 출력하기
변수의 값만 출력
: Console.WriteLine(a);
서식에 맞춰 출력
: Console.WriteLine("a={0}, b={1}",a,b);
문자열 보간
: Console.WriteLine($"a={a}, b={b}");