확장메서드1 [C#][Study] 확장 메서드(Extension Method) 1. 확장 메서드 - 기존 클래스의 기능을 확장하는 기법(상속과는 다름) - 클래스 외부에서 클래스의 메서드처럼 사용할 수 있는 새로운 메서드를 만들 수 있는 기능 2. 확장 메서드 생성방법 1) static class 2) static method 3) 첫번째 매개변수 this 키워드 using System; namespace StudyCSharp { class Program { static void Main(string[] args) { int a = 10; int b = 20; // int의 메서드처럼 IntToString 함수를 사용가능 string A = a.IntToString("aaaa"); string B = b.IntToString("bbbb"); Console.WriteLine(A); .. 2023. 10. 4. 이전 1 다음