![[C#] 14일차 - 97. LinkedList 클래스를 활용한 프로그램](https://img1.daumcdn.net/thumb/R750x0/?scode=mtistory2&fname=https%3A%2F%2Fblog.kakaocdn.net%2Fdn%2FqhUNa%2FbtqWVRTeTm1%2Fb9RB0s3VWzZtXvCqNCFMTK%2Fimg.png)
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace A097_UsingLinkedList { class Program { static void Main(string[] args) { LinkedList list = new LinkedList(); Random r = new Random(); for(int i = 0; i
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace A096_LinkedList { class Node { // internal은 같은 어셈블리 내부에서는 public 외부에서는 private와 같은 역할을 한다. // 어셈블리란 exe나 dll처럼 배포, 버전 관리 및 보안에 사용하기 위해 부분적으로 컴파일 된 코드 라이브러리 internal int data; internal Node next; // Node형 필드인 next는 리스트에서 다음 번 노드의 레퍼런스 public Node(int data) // 생성자 { this.da..
![[C#] 14일차 - 95. dynamic형을 사용하는 일반화 프로그램](https://img1.daumcdn.net/thumb/R750x0/?scode=mtistory2&fname=https%3A%2F%2Fblog.kakaocdn.net%2Fdn%2Fm0koc%2FbtqWUppxqm6%2Ff5kMlkTc8ZzNlpDq2DTbG1%2Fimg.png)
는 사용자가 만든 클래스를 포함해서 어떠한 자료형도 올 수 있는데 이 자료들이 더하거나 비교할 수 있는 데이터인지 알 수 없기 때문에 컴파일시 에러메세지가 나옴, 이를 해결하기 위해 dynamic키워드를 사용함 using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace A095_GenericMethodsUsingDynamic { class Program { static void Main(string[] args) { int[] a = { 10, 45, 32, 47, 85, 46, 93, 47, 50, 71 }; double[] b = { 0..
![[C#] 14일차 - 94. 일반화 클래스(제네릭 클래스)](https://img1.daumcdn.net/thumb/R750x0/?scode=mtistory2&fname=https%3A%2F%2Fblog.kakaocdn.net%2Fdn%2Fbej07M%2FbtqWUqaQNJe%2FDRJ2enrfOL8uICv5QH5Nb1%2Fimg.png)
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace A094_GenericClass { class MyClass { private T[] arr; private int count = 0; // 생성자 메소드 public MyClass(int length) { arr = new T[length]; count = length; } // 매개변수로 받은 값들을 배열로 저장 public void Insert(params T[] args) { for (int i = 0; i < args.Length; i++) arr[i] = args[i]; ..
![[C#] 14일차 - 93. 일반화 메소드(제네릭 메소드)](https://img1.daumcdn.net/thumb/R750x0/?scode=mtistory2&fname=https%3A%2F%2Fblog.kakaocdn.net%2Fdn%2FcfcNMX%2FbtqWNdwDAJV%2FT8nQOAeMHjZ4kDhr5D0cP0%2Fimg.png)
메소드 오버로딩을해서 사용할 수 있는것을 일반화 시켜 형식 매개변수를 사용한다 using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace A093_GenericMethod { class Program { static void Main(string[] args) { int[] a = { 1, 2, 3 }; double[] b = { 0.1, 0.2, 0.3 }; string[] s = { "tiger", "lion", "zebra" }; PrintArray(a); PrintArray(b); PrintArray(s); } static void ..