[C#] Extension Method (확장 메서드)


[C#] Extension Method (확장 메서드)

확장메서드는 기존의 클래스 기능을 확장합니다. 처음에 볼때는 이게 무슨의미인지 잘 모릅니다. 일단 규칙은 1. static 한정자로 수식하고, 2. 첫번째 매개변수는 this키워드를 사용합니다. 일단 예시를 봅시다. Colored By Color Scripter 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using MyExtension; namespace MyExtension { public static class IntegerExtension { public static int Square(this int myInt) ...


#IT·컴퓨터

원문링크 : [C#] Extension Method (확장 메서드)