본문 바로가기
728x90

전체 글239

[ C# 8일차 ] Generic 일반화 메서드 using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Collections; namespace Study09 { class App { //생성자 public App() { Console.WriteLine("App"); int[] arr0 = { 1, 2, 3 }; int[] arr1 = new int[3]; string[] arr2 = { "t", "r", "e" }; string[] arr3 = new string[3]; CopyArray(arr0, arr1); CopyArray(arr2, arr3); Hero[] arr4 = .. 2023. 1. 10.
[ C# 8일차 ] Struct 구조체 App Class using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Collections; namespace Study09 { class App { //생성자 public App() { Point3D point3d; Console.WriteLine("App"); //Console.WriteLine(point3d); point3d.x = 10; point3d.y = 10; point3d.z = 10; Console.WriteLine("{0} {1} {2}",point3d.x, point3d.y, point3d.z); Point3.. 2023. 1. 10.
[ C# 8일차 ] Collections_Hashtable 키와 값을 같이 저장! using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Collections; namespace Study09 { class App { //생성자 public App() { Console.WriteLine("App"); //컬렉션 인스턴스 생성 Hashtable table = new Hashtable(); table.Add(100, "홍길동"); //table.Add(100, "임꺽정"); //키 중복 불가. 에러 table.Add(102, new Hero()); table.Add("aaa", 1000); t.. 2023. 1. 10.
[ C# 8일차 ] Collections_Queue, Stack Queue 선입선출 using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Collections; namespace Study09 { class App { //생성자 public App() { Console.WriteLine("App"); Queue queue = new Queue(); queue.Enqueue(1); queue.Enqueue("홍길동"); queue.Enqueue(true); queue.Enqueue(null); queue.Enqueue(new Hero()); queue.Enqueue(new Queue()); qu.. 2023. 1. 10.
[ C# 8일차 ] Collections_ArrayList object 형식으로 박싱되어 원래의 데이터 형식으로 명시적 형변환 필요. App Class using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Collections; namespace Study09 { class App { ArrayList list; //변수 정의 //생성자 public App() { Console.WriteLine("App"); //모든 컬렉션을 사용하기 위해서는 //먼저 인스턴스를 생성해야 한다 list = new ArrayList(); //인스턴스를 반드시 생성하자 list.Add("홍길동"); //추가.. 2023. 1. 10.
[ C# 8일차 ] 프로퍼티 App Class using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace Study09 { class App { //생성자 public App() { Console.WriteLine("App"); //객체를 초기화 //방법1 //멤버변수 id의 한정자는 private //Hero hero = new Hero(100); //방법2 //멤버변수 id의 한정자는 public //Hero hero = new Hero(); //hero.id = 100; //방법3 //메서드 활용 //Hero hero = new Hero(); //hero.SetI.. 2023. 1. 10.
[C# 7일차] 배열 Inventory 과제 App Class using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace Day7 { class App { //생성자 public App() { Console.WriteLine("App"); Inventory inventory = new Inventory(5); inventory.PrintAllItems(); inventory.AddItem(new Item("장검")); inventory.PrintAllItems(); inventory.AddItem(new Item("장검")); //이미 장검이 있습니다. inventory.PrintAl.. 2023. 1. 10.
[C# 7일차] 배열을 이용한 맵 이동 App Class using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace Study07 { class App { int[,] arrHero = new int[2, 3]; int[,] arr = { {1, 3, 1 }, {1, 1, 2 } }; int rowIndex; int colIndex; //생성자 public App() { Console.WriteLine("App 생성자"); Console.WriteLine(); for (int i = 0; i < arr.GetLength(0); i++) { for(int j = 0; j < arr.. 2023. 1. 9.
[C# 7일차] 배열의 최대값과 최소값 최대값 구하기 배열 최대값변수에 배열의 첫번째 인덱스 값 저장 반복문i 최대값변수에 저장된 값이 배열[i]의 값보다 크다면 continue, 배열[i]의 값이 같거나 크다면 그 수 저장 1. 반복문으로 찾는 방법 2. 배열의 기능으로 찾는 방법 App Class using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace Study07 { class App { //생성자 public App() { Console.WriteLine("App 생성자"); Console.WriteLine(); //최대값 구하기 int[] arr = { 20, 10,.. 2023. 1. 9.
[C# 7일차] 배열과 input input: (1~5까지) input:2이면 배열에 2가 몇 개 있는지 출력 App Class using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace Study07 { class App { //생성자 public App() { Console.WriteLine("App 생성자"); Console.WriteLine(); int[] numbers = { 1, 3, 1, 3, 2, 3, 1, 4, 4, 5 }; int input; Console.Write("숫자를 입력하세요(1~5): "); input = Convert.ToInt32( Cons.. 2023. 1. 9.
[C# 7일차] 배열의 Class를 이용한 그룹화 App Class using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace Study07 { class App { //생성자 public App() { Console.WriteLine("App 생성자"); Console.WriteLine(); Student[] students = new Student[5]; students[0] = new Student("학생0", 00000, 50); //Student student0 = new Student(); //student0.id = 00000; //student0.name = "학생0"; //.. 2023. 1. 9.
[C# 7일차] 배열 복습 using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace Study07 { class App { //생성자 public App() { Console.WriteLine("App 생성자"); Console.WriteLine(); //길이가 5개인 배열을 생성하고 모든 요소의 값을 -1로 초기화 하세요 //같은 타입의 연속된 데이터들을 그룹화하고 관리하기 위함 //점수를 관리하기 위해 배열을 사용 int[] scores = new int[5]; Console.WriteLine("length: {0}", scores.Length); Console.. 2023. 1. 9.
728x90