본문 바로가기
1_12. Console.WriteLine 사용법 12345678910111213141516171819202122232425262728using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Threading.Tasks; namespace cshapExOne14{ class Program { static void Main(string[] args) { int n1 = 1; int n2 = 11; int n3 = 21; Console.WriteLine("{0} {1} {2}", n1, n2, n3); //일반적인 표기 Console.WriteLine("{0:d} {1:d} {2:d}", n1, n2, n3); //10진수 Console.Writ.. 2019. 1. 11.
1_11. 연산자 12345678910111213141516171819202122232425262728using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Threading.Tasks; namespace cshapExOne13{ class Program { static void Main(string[] args) { /* * 수식 연산자 - +,-,*,/,% * 할당 연산자 - =, +=, -+, *=, /=, %= * 증가/감소 연산자 - ++, -- * 논리 연산자 - &&, ||, ! * 관계연산자 - , ==, !=, >=, >, 2019. 1. 11.
1_10. enum(열거형 상수) 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Threading.Tasks; namespace cshapExOne12{ enum Food0 : byte { Apple, Water, Rice } enum Food1 { Apple, Water, Rice } enum Food2 { Apple = 2, Water, Rice } enum Food3 { Apple = 5, Water = 10, Ri.. 2019. 1. 9.
1_9.형변환3 / 상수 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Threading.Tasks; namespace cshapExOne11{ class Program { static void Main(string[] args) { /* * 부동 소수점과 정수형 사이의 형변환 * */ float f1 = 1.1234f; int n1 = (int)f1; // 소수자리는 무조건 버림 Console.WriteLine(f1).. 2019. 1. 9.
1_8.형변환2(2의보수) 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Threading.Tasks; namespace cshapExOne10{ class Program { static void Main(string[] args) { /* * 부호가 있는 정수형과 부호가 없는 정수형 사이의 형변환 * * 2의보수가 나온이유 * 1) * 0000 0000 -> 0 * 1000 0000 -> -0? * * 2) * 1+(-1) = ?.. 2019. 1. 9.
1_7.형변환1 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Threading.Tasks; namespace cshapExOne9{ class Program { static void Main(string[] args) { /* * 1. 데이터 형식 변환(형변환) * - 변수를 다른 데이터 형식에 옮기는 것을 의미 * - 소괄호( )컨버전 연산자 사용 * * 2. 형변환의 종류 * - 크기가 서로 다른 정수형 사이의 형변환 * ex) * in.. 2019. 1. 9.
1_6.boxing/unboxing 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Threading.Tasks; namespace cshapExOne8{ class Program { static void Main(string[] args) { /* * object형식 - 참조형식 * (실제데이터는 힙에 저장하고 스택에서 참조) * * C#은 모든 데이터를 다룰 수 있는 object형식을 제공 * C#의 컴파일러는 어.. 2019. 1. 7.
1_5.reference타입 123456789101112131415161718192021222324252627282930313233using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Threading.Tasks; namespace cshapExOne7{ class Program { static void Main(string[] args) { /* * value타입과 reference타입 * * value타입(값 형식) - 변수가 값을 담는 데이터 형식 * reference타입(참조형식) - 변수가 값 대신에 그 값이 있는 곳의 * 위치의 값(주소)을 담고있는 형식 * * cf)----------------------.. 2019. 1. 7.
1_4.null과 nullable ( reference타입/value타입 ) 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Threading.Tasks; namespace cshapExOne6{ class Program { static void Main(string[] args) { /* * NULL(null) : 어떤 변수가 데이터를 가지고 있지 않을때 * 즉, 메모리상에 어떤 데이터도 갖고 있지 않을 때 사용하는 키워드 * * reference 타입 * - NULL(null)을 가질 수 있는 데.. 2019. 1. 6.
1_3.접미어와 MaxValue/MinValue 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Threading.Tasks; namespace cshapExOne5{ class Program { static void Main(string[] args) { // char - 2바이트 char a = 'a'; char b = 'b'; char c = 'c'; char d = 'd'; char e = 'e'; C.. 2019. 1. 6.