본문 바로가기

C#

2022.11.01.TIL

기본 틀:

class Hello
{
	static void Main()
    {
    	System.Console.WriteLine("Hello, world!");
    }
}

using 문으로 System 네임스페이스 생략 가능

using System;

class Hello
{
	static void Main()
    {
    	Console.WriteLine("Hello, world!");
    }
}

C# 콘솔 입출력:

Console.Read() : 한글자 읽기(입력받기)

Console.ReadLine(): 한줄 읽기

Console.Write(string): 문자열 출력

Console.WriteLine(string): 문자열을 출력하고 줄바꾸기

 

C#에서 자료형:

  • sbyte: 8bit 부호있는 정수
  • short: 16bit 부호있는 정수
  • int: 32bit 부호있는 정수
  • long: 64bit 부호있는 정수

 

  • byte: 8bit 부호없는 정수
  • ushort: 16bit 부호없는 정수
  • uint: 32bit 부호없는 정수
  • ulong: 64bit 부호없는 정수

 

  • float: 32bit 부동 소수점
  • double: 64bit 부동 소수점

 

  • decimal: 128bit 소수

var: 지역변수로만 사용 가능한 명시적 형식(컴파일러가 자료형을 결정함)

'C#' 카테고리의 다른 글

2022.11.02.TIL  (0) 2022.11.02