c# comparison

    [C#] Collection Method

    [C#] Collection Method

    1. IndexOf, FindIndex, FindAll using System; using System.Collections.Generic; class Program { public static bool Divide3(int n) { return n % 3 == 0; } static void Main() { List c1 = new List() {1, 2, 3, 1, 2, 3, 1, 2, 3, 10}; // 값 검색 Console.WriteLine(c1.IndexOf(3)); // 2 Console.WriteLine(c1.IndexOf(3, 5)); // 5 Console.WriteLine(c1.IndexOf(3, 6, 2)); // -1 // 조건 검색 : 3의 배수 찾기 Console.WriteLin..

    [C#] Delegate Example

    [C#] Delegate Example

    1. 예제 using System; class Program { public static void Swap(ref int a, ref int b) { int temp = a; a = b; b = temp; } public static void Sort(int[] arr) { int sz = arr.GetLength(0); for(int i = 0; i arr[j]) Swap(ref arr[i], ref arr[j]); } } } static void Main() { int[] x = {1, 3, 5, 7, 9, 2, 4, 6, 8, 10}; Sort(x); foreach(int n in x) ..