C#프로그래밍 64

스타크래프트 유닛, 건물

Main 메서드 [공통] using System; namespace LearnDotnet { internal class Program { static void Main(string[] args) { new App(); //new: 인스턴스 호출[값이라 변수에 넣을 수 있음] } } } 1. App 클래스 [TerranCommandCenter] using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace LearnDotnet { internal class App { //데이터 //생성자 public App() { TerranCommandCent..

C#프로그래밍 2023.07.21

클래스 정의[중요]

클래스는 사용자 지정 형식이다. - 참조형식 : 스택(값이 있는주소), 힙(값) - null : 아무것도 참조하지 않는 값 string(참조형식) string name = null; 클래스 정의 : 값이 생겨나지 않음 new 키워드를 사용해야만 값이 생겨남 객체, 개체, 인스턴스 : 클래스의 값 (메모리에 저장되는) 기본값이 null이다 클래스 정의(선언) 객체 단위로 생각해야 한다 ------------------------------ 클래스 이름 ------------------------------ 데이터 기능 ------------------------------ ------------------------------ 챔피언 ------------------------------ 데이터 이름 체력..

C#프로그래밍 2023.07.21

if, switch

using System; namespace LearnDotnet { internal class Program { static void Main(string[] args) { //소지골드 : 500골드 //장검 : 100골드 //단검 : 80골드 //활 : 120골드 //구매 하고자 하는 아이템 이름을 입력하세요. : 장검 //장검을 구매 했습니다. (-100골드) //소지골드 : 400골드 int haveMoney = 500; int longSwordMoney = 100; int shortSwordMoney = 80; int bowMoney = 120; Console.WriteLine("소지골드 : {0}골드\n", haveMoney); Console.WriteLine("장검 : 100골드"); Cons..

C#프로그래밍 2023.07.21

산술연산자, 복합할당식

using System; namespace LearnDotnet { internal class Program { static void Main(string[] args) { int i = 123; //int 값형식 값이 스택 메모리에 저장 object obj = i; //박싱(암시적) i의 값이 힙메모리에 저장됨 int ii = (int)obj; //언박싱(명시적) ConsoleKeyInfo info = Console.ReadKey(); Console.WriteLine("Key: {0}", info.Key); Console.WriteLine("KeyChar: {0}", info.KeyChar); //증가 연산자 //++x, x++ //감소 연산자 //--x, x-- //나머지 연산자 //% Console..

C#프로그래밍 2023.07.20