--- id: csharp-method-overloading title: "C# Method Overloading" category: "Programming_Language" status: "draft" verification_status: "conceptual" canonical_id: "" aliases: ["overload same name different parameters", "C# 메서드 오버로딩"] duplicate_of: "" source_trust_level: "B" confidence_score: 0.83 created_at: 2026-07-04 updated_at: 2026-07-04 review_reason: "" merge_history: [] tags: ["csharp", "programming-language", "w3schools", "methods", "overloading"] raw_sources: ["https://www.w3schools.com/cs/cs_method_overloading.php"] applied_in: [] github_commit: "" --- # [[CSharp Method Overloading]] ## 🎯 한 줄 통찰 (One-line insight) Method overloading in C# (`PlusMethod(int, int)` and `PlusMethod(double, double)` sharing one name) is conceptually and syntactically identical to C++'s function overloading already covered in Topic_CPP — same rule ("as long as the number and/or type of parameters are different"), same motivating example structure (separately-named `PlusMethodInt`/`PlusMethodDouble` refactored into one overloaded `PlusMethod`) — reconfirming that C#'s object-oriented mechanics inherited directly from C++ rather than diverging, unlike the parameter-passing extensions (named arguments) covered in the immediately preceding chapter. [S1] ## 🧠 핵심 개념 (Core concepts) - **Method overloading** — multiple methods sharing the SAME name but differing in number and/or type of parameters. [S1] - **Compiler resolves by signature** — the compiler picks the correct overload based on the argument types/count supplied at the call site. [S1] - **Motivation** — avoids needing distinctly-named methods (`PlusMethodInt`, `PlusMethodDouble`) for functionally identical operations across different types. [S1] ## 📖 세부 내용 (Details) - Before overloading (distinct names): `static int PlusMethodInt(int x, int y) { return x + y; } static double PlusMethodDouble(double x, double y) { return x + y; }`. [S1] - After overloading (shared name): `static int PlusMethod(int x, int y) { return x + y; } static double PlusMethod(double x, double y) { return x + y; }` — called as `PlusMethod(8, 5)` (resolves to int version) and `PlusMethod(4.3, 6.26)` (resolves to double version). [S1] - General signature examples cited: `int MyMethod(int x)`, `float MyMethod(float x)`, `double MyMethod(double x, double y)` — all valid overloads of `MyMethod`. [S1] ## ⚖️ 모순 및 업데이트 (Contradictions & updates) - **C++의 함수 오버로딩과 개념·문법이 동일**: 매개변수 개수/타입만 다르면 같은 이름을 여러 메서드가 공유할 수 있다는 규칙과 예제 구성 방식이 Topic_CPP의 Function Overloading 챕터와 차이가 없다는 점이 확인됨 — 이전 챕터(Named Arguments)의 C/C++ 대비 확장과는 달리, 오버로딩은 C++에서 그대로 계승된 메커니즘. [S1] ## 🛠️ 적용 사례 (Applied in summary) 서로 다른 이름의 두 메서드(PlusMethodInt/PlusMethodDouble)를 하나의 오버로드된 PlusMethod로 리팩터링하는 예제가 원문에서 직접 실전 활용 사례로 제시됨. [S1] ## 💻 코드 패턴 (Code patterns) Overloading the same method name for different parameter types (C#): ```csharp static int PlusMethod(int x, int y) { return x + y; } static double PlusMethod(double x, double y) { return x + y; } static void Main(string[] args) { int myNum1 = PlusMethod(8, 5); // resolves to int version double myNum2 = PlusMethod(4.3, 6.26); // resolves to double version } ``` ## ✅ 검증 상태 및 신뢰도 - **상태:** draft - **검증 단계:** conceptual - **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body) - **신뢰 점수:** 0.83 - **중복 검사 결과:** 신규 생성 (New discovery) ## 🔗 지식 그래프 (Knowledge Graph) - **상위/루트:** [[C# Tutorial]] - **관련 개념:** [[CSharp Method Parameters Named Args]], [[CSharp Method Parameters Return]], [[CPP Function Overloading]] - **참조 맥락:** Methods 섹션의 마지막 챕터 — Return Values 챕터로 이어짐. ## 📚 출처 (Sources) - [S1] W3Schools — C# Method Overloading — https://www.w3schools.com/cs/cs_method_overloading.php ## 📝 변경 이력 (Change history) - 2026-07-04: Initial draft synthesized from the W3Schools "C# Method Overloading" page (Astra wiki-curation, P-Reinforce v3.1 format).