본문 바로가기

전체 글171

[7] C# 조건문 (C# if else statement) 프로그램 개발 할때 가장 많이 사용하면서 중요한 개념인 if else 구문에 대해서 알아 보겠습니다. (1) if else 문법 위 그림에서 처럼 조건값이 True이면 if {}를 수행하고 False이면 else{} 를 수행하는 것입니다.프로그래머 4자 성어이 백문이 불여 일타인 아래 샘플 코드를 보면 이해가 좀더 쉬울 것입니다. void If_Else_Sample() { // local variable definition int a = 100; // check the boolean condition if (a < 20) { // if condition is true then print the following Console.WriteLine("a is less than 20"); } else { // .. 2015. 2. 23.
[6] C# 비트와이즈 오퍼레이터. Misc(기타) 오퍼레이터(Bitwise, Misc Operators) 1) 비트 연산 오퍼레이터 (Bitwise Operators)2진수 비트단위 연산에 사용하는 연산자입니다. 외울려고하지 말고 이해를 하고 지나가도록 노력해 봅시다. 대학교를 졸업했으면 거의 한번에 이해가 다될 것입니다. [연산 예제]A값은 60, B값은 13일라고 가정하고 아래 연산을 계산해 보겠습니다. A = 0011 1100 B = 0000 1101 ----------------- A&B = 0000 1100 A|B = 0011 1101 A^B = 0011 0001 ~A = 1100 0011 void BitwiseOperators() { int a = 60; /* 60 = 0011 1100 */ int b = 13; /* 13 = 0000 1101 */ int c = 0; c = a & b; /* 1.. 2015. 2. 23.
[5] C# 산술 연관 논리 오퍼레이터 (C# operators) 오퍼레이터를 간단하게 설명하면 C# Compiler가 특정 수학적 수식 또는 논리적 변화를 수행하는 심볼(키워드)라고 생각하시면 됩니다. 1) 산술 오퍼레이터 ( Arithmetic Operators) void ArithmeticOperators(string[] args) { int a = 21; int b = 10; int c; c = a + b; Console.WriteLine("Line 1 - Value of c is {0}", c); c = a - b; Console.WriteLine("Line 2 - Value of c is {0}", c); c = a * b; Console.WriteLine("Line 3 - Value of c is {0}", c); c = a / b; Console.Writ.. 2015. 2. 23.
[4] C# 변수, 상수, 문자 (C# Variables, Constants, Literals) 1) C# 변수 Variables 크게 5가지 변수 종류가 있습니다. 다른 언어와 다른점은 아래 표 마지막에 이는 Nullable Types 입니다. 종류(Type) 예제(Example) Integral types sbyte, byte, short, ushort, int, uint, long, ulong and char Floating point types float and double Decimal types decimal Boolean types true or false values, as assigned Nullable types Nullable data types int? num = null; // num 값은 null 이다. if (num.HasValue) { System.Console.Writ.. 2015. 2. 23.