본문 바로가기

공부/C#14

C# 공부(12) 111~124(Part3 End && C# 언어 공부 End) 111. SortedList와 SortedListusing System; using System.Collections.Generic; namespace P111 {     class Program     {         static void Main(string[] args)         {             SortedList s1 = new SortedList();             s1.Add(3, "C");             s1.Add(4, "D");             s1.Add(1, "A");             s1.Add(2, "B");             for (int i = 0; i             Console.WriteLine();            .. 2024. 8. 28.
C# 공부(11) 101~110 101. 큐를 이용한 프로그램class Program {     static void Main()     {         Random r = new Random();         Queue queue = new Queue();         for (int i = 0; i         {             queue.Enqueue(r.Next(100) / 100.0f);         }         queue.Print();         for (int i = 0; i         {             queue.Dequeue();             queue.Print();         }     } } 결과0.64 0.77 0.51 0.53 0.38 0.77 0.51 0.53.. 2024. 8. 27.
C# 공부(10) 93~100 93. 일반화 메소드using System; namespace P93 {     class Program     {         static void Main(string[] args)         {             int[] a = { 1, 2, 3 };             double[] d = { 0.1, 0.2, 0.3 };             string[] s = { "AB", "BC", "CD" };             Print(a);             Print(d);             Print(s);         }         private static void Print(T[] values)         {             foreach (var .. 2024. 8. 27.
C# 공부(10) 91~92(Part2 End) 91. 선택적 인수와 명명된 인수using System; namespace P91 {     class Program     {         static int Power(int x, int y = 2)         {             int result = 1;             for (int i = 0; i             {                 result *= x;             }             return result;         }         static int Area(int h, int w)         {             return h * w;         }         static void Print(int a, int .. 2024. 8. 26.