C#

C#/수업 과제

C# 인벤토리 만들기

문제 구현 App Class using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace study01 { internal class App { public App() { Inventory inventory = new Inventory(5); inventory.AddItem(new Weapon("장검")); inventory.PrintItem(); inventory.DeleteItem("장검"); inventory.PrintItem(); inventory.AddItem(new Weapon("장검")); inventory.PlusCapacity..

C#/개인공부

LINQ 복습

using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Xml.Linq; using static reviewAll01.Earth; //using static reviewAll01.Earth; // 2022기능으로 알아서 클래스를 가져오더라 namespace reviewAll01 { class App { int[] testSets = { 1, 2, 3, 4, 5, 6, 7 }; List lists = new List(); public App() { var testSets1 = from testset in testSets.ToList(..

C#/개인공부

Func 대리자 & Action 대리자 복습

using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Xml.Linq; using static reviewAll01.Earth; //using static reviewAll01.Earth; // 2022기능으로 알아서 클래스를 가져오더라 namespace reviewAll01 { class App { int sum; int sum1; public App() { //func 문 사용 Func func1 = (x, y) => x + y; // func 대리자 선언 후 매개변수 + 식 대입 ("," 빼먹지 말것) Console.Writ..

C#/개인공부

변하지 않는 데이터 역직렬화 복습

App Class using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using System.IO; using Newtonsoft.Json; namespace Study000 { class App { public App() { //json 문자열화 후 객체화하는 기본 과정 복습 string path = "./item_data.json"; //경로를 담을 변수 초기화 string jason = File.ReadAllText(path); //json파일을 불러와 string형식으로 변경 Console.WriteLine(jason); // 불러온 파일이 맞..

C#/개인공부

람다식 & 문 복습

App Class using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Xml.Linq; using static reviewAll01.Earth; //using static reviewAll01.Earth; // 2022기능으로 알아서 클래스를 가져오더라 namespace reviewAll01 { class App { //람다문 사용전 delegate 선언 (대리자 선언) delegate int Calculate(int x, int y); delegate void Test(); delegate string Test2(); publ..

C#/개인공부

열거형 복습

App Class using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using static reviewAll01.Earth; //using static reviewAll01.Earth; // 2022기능으로 알아서 클래스를 가져오더라 namespace reviewAll01 { class App { Earth earth = new Earth(); // 클래스 생성 public App() { //enum * 열거형식 복습 Console.WriteLine(Seasons.Summer); //Seasons 타입의변수명 출력 Console.WriteLine((..

C#/수업 내용

2023.01.13 오전 수업 내용 : 직렬화

직렬화 복습 Item class using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace Study12 { //[Serializable] Newtosoft.Json에서는 불필요함 class Item { //맴버 변수 //직렬화 할 객체의 필드 한정자는 public 이어야 한다. public int damage; public string name; //생성자 public Item() { } } } App Class using System; using System.Collections.Generic; using System.Linq; usin..

C#/수업 내용

상점 목록 및 미션 목록 & 보상 출력 (역직렬화 이용)

상점 아이템 목록 using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using System.IO; using Newtonsoft.Json; namespace Study013 { class App { public App() { //Json 데이터 불러오기 string json = File.ReadAllText("./item_data.json"); //foreach를 사용하여 Dictionary 컬렉션에 할당 하는 방법 //ItemData[] itemDatas = JsonConvert.DeserializeObject(json); //Dictionary ..

C#/수업 과제

Jason 직렬화 역직렬화 과제

단검 직렬화 (객체를 문자열로) App Class using System; using System.Collections.Generic; using System.IO; using System.Linq; using Newtonsoft.Json; namespace Study11 { class App { //생성자 public App() { //객체를 만들고 직렬화 해서 JSON형식 (문자열) 파일로 저장 Item item = new Item("단검,",5); //직렬화 : 아이템 객체를 넣어 주면 json문자열을 반환 string json = JsonConvert.SerializeObject(item); Console.WriteLine(json); //저장 File.WriteAllText("dagger.jso..

C#/수업 내용

2023.01.12 오전수업 : LINQ

객체 이니셜라이저 예제 App Class using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace Study011 { class App { public string Name { get; set; } public int damage; //생성자 public App() { //생성자 매개변수 활용 Item item = new Item("홍길동",10); // 두번째 방법 Item item2 = new Item(); item.Name = "장검"; item.damage = 10; //개체 이니셜라이저 //해당 객체가 가지고 있는 속성(프로퍼티)..

Bueong_E
'C#' 카테고리의 글 목록 (2 Page)