namespace Cshap
{
class Program
{
static void Main(string[] args)
{
// int 정수형 (1 2 3 4 5)
// float 실수형 (3.14)
// string 문자열 ("YIDO")
// Bool 불리언 (true / false)
// [데이터 타입] [이름];
//int hp;
// [이름] = [값]
//hp = 100;
// [데이터 타입] [이름] = [값]
int hp = 100;
int maxHp;
// TODO
maxHp = hp;
Console.WriteLine(hp);
}
}
}

namespace Cshap
{
class Program
{
static void Main(string[] args)
{
// int 정수형 (1 2 3 4 5)
// float 실수형 (3.14)
// string 문자열 ("YIDO")
// Bool 불리언 (true / false)
// 십진법
// 0 1 2 3 4 5 6 7 8 9 10
int hp = 100;
// 이진법
// 0b00 0b01 0b10 0b11
hp = 0b01100100;
// 십육진법
// 0 1 2 3 4 5 6 7 8 9 A B C D E F
hp = 0x64;
}
}
}
namespace Cshap
{
class Program
{
static void Main(string[] args)
{
// int 정수형 (1 2 3 4 5)
// float 실수형 (3.14)
// string 문자열 ("YIDO")
// Bool 불리언 (true / false)
// 4byte
float a = 3.14223424f;
// 8byte
double b = 3.14;
Console.WriteLine(a);
}
}
}
namespace Cshap
{
class Program
{
static void Main(string[] args)
{
// int 정수형 (1 2 3 4 5)
// float 실수형 (3.14)
// string 문자열 ("YIDO")
// Bool 불리언 (true / false)
string name;
name = "YIDO";
char ch;
ch = 'Y';
Console.WriteLine(name);
// 출력 : YIDO
Console.WriteLine(ch);
// 출력 : Y
}
}
}
namespace Cshap
{
class Program
{
static void Main(string[] args)
{
// int 정수형 (1 2 3 4 5)
// float 실수형 (3.14)
// string 문자열 ("YIDO")
// Bool 불리언 (true / false)
// ex
// isAdmin = true / false;
// soundOnOff = true / fasle;
// autoPlay = true / false;
bool a;
a = true;
a = false;
}
}
}
namespace Cshap
{
class Program
{
static void Main(string[] args)
{
// int 정수형 (1 2 3 4 5)
// float 실수형 (3.14)
// string 문자열 ("YIDO")
// Bool 불리언 (true / false)
// 4byte
int a = 100;
// 2byte
//short b = a; // 용량이 작아서 에러 발생
short b = (short)a;
float c = a;
int d = (int)c;
}
}
}
namespace Cshap
{
class Program
{
static void Main(string[] args)
{
// int 정수형 (1 2 3 4 5)
// float 실수형 (3.14)
// string 문자열 ("YIDO")
// Bool 불리언 (true / false)
// int a = 100;
// string b = (string)a; 불가능 (string은 클래스이기에)
// string -> int
//string input;
//input = Console.ReadLine();
//int number = int.Parse(input); // string을 int로 변환
//Console.WriteLine(input);
// int -> string
int hp = 100;
int maxHp = 100;
//string.Format("당신의 HP는 {0}/{1} 입니다.", hp, maxHp);
//string message = string.Format("당신의 HP는 {0}/{1} 입니다.", hp, maxHp);
//Console.WriteLine(message);
string message = $"당신의 HP는 {hp} / {maxHp}입니다.";
Console.WriteLine(message);
}
}
}
namespace Cshap
{
class Program
{
static void Main(string[] args)
{
int hp = 100;
hp = hp - 5;
Console.WriteLine(hp);
// 산술 연산
// + - * / %
// 몫 나머지
int a = 10 / 3;
int b = 10 % 3;
Console.WriteLine(a);
Console.WriteLine(b);
int c = 10;
c += 5; // c = c + 5;
c++; // c += 1; c = c + 1;
Console.WriteLine(c++); // c를 출력하고 ++ 하겠다. -> c = 16
Console.WriteLine(++c); // ++하고 c를 출력하겠다. -> c = 18
}
}
}
namespace Cshap
{
class Program
{
static void Main(string[] args)
{
// 비교 연산
// < <= > >= == !=
int hp = 100;
int maxHp = 100;
bool isFullHp = (hp == maxHp);
Console.WriteLine(isFullHp);
bool isAlive = (hp > 0);
Console.WriteLine(isAlive);
int level = 10;
bool canEnterDungeon = (level <= 5);
Console.WriteLine(canEnterDungeon);
}
}
}
namespace Cshap
{
class Program
{
static void Main(string[] args)
{
bool isTall = true; // 키가 크다
bool isSmart = false; // 똑똑하다
// and && / or || / not !
int level = 1;
int gold = 100;
bool isHighLevel = (level >= 10);
bool isRich = (gold >= 1000);
bool cnaEnter = isHighLevel && isRich;
}
}
}