//데이터 타입
//c++이랑은 좀 차이가 있다.
//string
//c++에서는 기본적으로 없고 STL로 구현되어있다.
//C#에서 메모리 구조상에서 바뀌지 않는다. 새로 메모리 공간을 만든다.
//string str = string.Format("string test : {0} {1} {0}", 10, "문자");
//Console.WriteLine(str);
//int형 크기, 최소값, 최대값
//Console.WriteLine("int : {0} byte {1} ~ {2}" ,
// sizeof(int), int.MinValue, int.MaxValue); //int
Console.WriteLine("int : {0} byte {1:N} ~ {2:N}", //N 기본 숫자 포맷팅 정수 셋째 자리마다 , 소수점아래 2자리
sizeof(int), int.MinValue, int.MaxValue); //int
Console.WriteLine("uint : {0} byte {1:N} ~ {2:N}",
sizeof(uint), uint.MinValue, uint.MaxValue); //unsigned int
Console.WriteLine("long : {0} byte {1:#,#} ~ {2:#,#}", //#,#만 하면 소수점 없이 숫자 포맷 가능
sizeof(long), long.MinValue, long.MaxValue); //long
//UInt16; UInt32; UInt64; //숫자 bit짜리 int;
Console.WriteLine("decimal : {0} byte {1:#,#} ~ {2:#,#}", //#,#만 하면 소수점 없이 숫자 포맷 가능
sizeof(decimal), decimal.MinValue, decimal.MaxValue); //10진수
Console.WriteLine("byte : {0} byte {1} ~ {2}",
sizeof(byte), byte.MinValue, byte.MaxValue); //byte 0 ~ 255
Console.WriteLine("sbyte : {0} byte {1} ~ {2}",
sizeof(sbyte), sbyte.MinValue, sbyte.MaxValue); //sbyte -128 ~ 127
//char
//C#에서는 타입 체킹이 엄격하다.
//기본적으로 unicode를 사용한다.
//글자 하나를 받는 의미가 크다.
char a = '글'; //그래서 한글도 들어갈 수 있다.(c++에서는 한글은 2byte가 필요한데 char는 1byte이다.)
char b = 'a';
Console.WriteLine("char : {0} byte {1} ~ {2}",
sizeof(char), char.MinValue, char.MaxValue); //char \0 ~ 0xffff
Console.WriteLine("float : {0} byte {1} ~ {2}",
sizeof(float), float.MinValue, float.MaxValue); //float
Console.WriteLine("double : {0} byte {1} ~ {2}",
sizeof(double), double.MinValue, double.MaxValue); //double
Console.WriteLine("bool : {0} byte {1} ~ {2}",
sizeof(bool), bool.FalseString, bool.TrueString); //bool
//데이터 타입 끝
'공부 > C#' 카테고리의 다른 글
사칙연산 (0) | 2016.05.04 |
---|---|
배열 (0) | 2016.05.04 |
string 처리 기본 (0) | 2016.05.04 |
[잡담]C# 공부 첫날 소감 (0) | 2016.05.03 |
정수, 실수 출력 (0) | 2016.05.03 |