--- id: csharp-methods title: "C# Methods" category: "Programming_Language" status: "draft" verification_status: "conceptual" canonical_id: "" aliases: ["static void method C#", "PascalCase methods", "C# λ©”μ„œλ“œ"] duplicate_of: "" source_trust_level: "B" confidence_score: 0.84 created_at: 2026-07-04 updated_at: 2026-07-04 review_reason: "" merge_history: [] tags: ["csharp", "programming-language", "w3schools", "methods"] raw_sources: ["https://www.w3schools.com/cs/cs_methods.php"] applied_in: [] github_commit: "" --- # [[CSharp Methods]] ## 🎯 ν•œ 쀄 톡찰 (One-line insight) C# calls these "methods" and only parenthetically notes "also known as functions" β€” a terminology choice with real teeth, since the Syntax chapter's rule that ALL code must live inside a class means C# genuinely has no free-standing functions the way C++ does; every "function" is necessarily a method of SOME class (even `Main()` itself lives inside `class Program`), and the naming-convention split flagged back in the Identifiers chapter (variables lowercase-first) is completed here: methods are explicitly recommended to start UPPERCASE (`MyMethod`), giving C# a hard camelCase-vs-PascalCase split by identifier KIND that neither C nor C++ enforces as a style convention. [S1] ## 🧠 핡심 κ°œλ… (Core concepts) - **Method** β€” a block of code that only runs when called; used to perform actions and enable code reuse (define once, use many times). [S1] - **`static void MethodName() { ... }`** β€” the minimal method skeleton, defined inside a class. [S1] - **`static`** β€” means the method belongs to the CLASS itself, not to an object/instance of the class (object-based method access deferred to a later chapter). [S1] - **`void`** β€” means the method has no return value (deferred detail to the Return Values chapter). [S1] - **PascalCase convention** β€” method names should start with an UPPERCASE letter for readability, in contrast to the lowercase-starting convention recommended for variable names. [S1] - **Calling a method** β€” `MethodName();` β€” same method can be called any number of times, each call re-executing the body independently. [S1] ## πŸ“– μ„ΈλΆ€ λ‚΄μš© (Details) - Method definition: `class Program { static void MyMethod() { // code to be executed } }`. [S1] - Single call: `static void Main(string[] args) { MyMethod(); }` β†’ outputs `"I just got executed!"`. [S1] - Repeated calls: calling `MyMethod();` three times in `Main()` prints the same message three times. [S1] ## βš–οΈ λͺ¨μˆœ 및 μ—…λ°μ΄νŠΈ (Contradictions & updates) - **C++와 달리 클래슀 λ°–μ˜ 자유 ν•¨μˆ˜κ°€ μ‘΄μž¬ν•˜μ§€ μ•ŠμŒ**: Syntax μ±•ν„°μ—μ„œ ν™•μΈλœ "λͺ¨λ“  μ½”λ“œλŠ” class μ•ˆμ—" 원칙 λ•Œλ¬Έμ—, C#은 C++처럼 클래슀 밖에 λ…λ¦½μ μœΌλ‘œ μ‘΄μž¬ν•˜λŠ” 자유 ν•¨μˆ˜λ₯Ό κ°€μ§ˆ 수 μ—†κ³  λͺ¨λ“  ν•¨μˆ˜κ°€ λ°˜λ“œμ‹œ μ–΄λ–€ class의 λ©”μ„œλ“œλΌλŠ” 점이 확인됨 β€” Main() μžμ²΄λ„ Program 클래슀 μ•ˆμ— 있음. [S1] - **λ³€μˆ˜λŠ” μ†Œλ¬Έμž, λ©”μ„œλ“œλŠ” λŒ€λ¬Έμžλ‘œ μ‹œμž‘ν•˜λŠ” λͺ…λͺ… κ·œμΉ™ 뢄리가 완성됨**: Identifiers μ±•ν„°μ—μ„œ μ˜ˆκ³ ν–ˆλ˜ λ³€μˆ˜ lowercase μ‹œμž‘ 관둀에 이어, 이번 μ±•ν„°λŠ” λ©”μ„œλ“œλͺ…을 uppercase둜 μ‹œμž‘ν•˜λ„λ‘ λͺ…μ‹œμ μœΌλ‘œ ꢌμž₯ν•œλ‹€λŠ” 점이 확인됨 β€” μ‹λ³„μž μ’…λ₯˜(λ³€μˆ˜ vs λ©”μ„œλ“œ)에 따라 λŒ€μ†Œλ¬Έμž κ΄€λ‘€κ°€ κ°ˆλΌμ§€λŠ” C#만의 μŠ€νƒ€μΌ κ·œμΉ™. [S1] ## πŸ› οΈ 적용 사둀 (Applied in summary) ν˜„μž¬ 발견된 μ‹€μ œ 적용 사둀가 μ—†μŠ΅λ‹ˆλ‹€ β€” "I just got executed!"λ₯Ό 좜λ ₯ν•˜λŠ” λ©”μ„œλ“œλ₯Ό μ •μ˜ν•˜κ³  μ—¬λŸ¬ 번 ν˜ΈμΆœν•˜λŠ” μ˜ˆμ œκ°€ μ›λ¬Έμ—μ„œ μ œμ‹œλ¨. [S1] ## πŸ’» μ½”λ“œ νŒ¨ν„΄ (Code patterns) Minimal method definition and repeated calls (C#): ```csharp static void MyMethod() { Console.WriteLine("I just got executed!"); } static void Main(string[] args) { MyMethod(); MyMethod(); MyMethod(); } ``` ## βœ… 검증 μƒνƒœ 및 신뒰도 - **μƒνƒœ:** draft - **검증 단계:** conceptual - **좜처 신뒰도:** B (W3Schools β€” widely used educational reference, not a primary standards body) - **μ‹ λ’° 점수:** 0.84 - **쀑볡 검사 κ²°κ³Ό:** μ‹ κ·œ 생성 (New discovery) ## πŸ”— 지식 κ·Έλž˜ν”„ (Knowledge Graph) - **μƒμœ„/루트:** [[C# Tutorial]] - **κ΄€λ ¨ κ°œλ…:** [[CSharp Arrays Multi]], [[CSharp Method Parameters]], [[CSharp Variables Identifiers]], [[CPP Functions]] - **μ°Έμ‘° λ§₯락:** Methods μ„Ήμ…˜ β€” Method Parameters μ±•ν„°λ‘œ 이어짐. ## πŸ“š 좜처 (Sources) - [S1] W3Schools β€” C# Methods β€” https://www.w3schools.com/cs/cs_methods.php ## πŸ“ λ³€κ²½ 이λ ₯ (Change history) - 2026-07-04: Initial draft synthesized from the W3Schools "C# Methods" page (Astra wiki-curation, P-Reinforce v3.1 format).