Files
2nd/10_Wiki/Dev/Topic_CSharp/CSharp_Method_Parameters_Default.md
T
Antigravity Agent 1cfd3bbb56 docs(10_Wiki): 위키 구조 정리 — 언어 튜토리얼 카테고리 폴더 제거 + 신규 자산 동기화
Topic_CSS/Topic_HTML/Topic_JavaScript/Topic_Prompt/Topic_Comfyui 등 기존 카테고리 폴더를 정리하고,
Topic_Graphic/Dev 등 신규 산출물과 Topics 내부 세션/메모리 기록을 동기화.
2026-07-05 00:10:59 +09:00

3.9 KiB

id, title, category, status, verification_status, canonical_id, aliases, duplicate_of, source_trust_level, confidence_score, created_at, updated_at, review_reason, merge_history, tags, raw_sources, applied_in, github_commit
id title category status verification_status canonical_id aliases duplicate_of source_trust_level confidence_score created_at updated_at review_reason merge_history tags raw_sources applied_in github_commit
csharp-method-parameters-default C# Default Parameter Value Programming_Language draft conceptual
optional parameter C#
default value = C#
C# 기본 매개변수 값
B 0.83 2026-07-04 2026-07-04
csharp
programming-language
w3schools
methods
default-parameters
https://www.w3schools.com/cs/cs_method_parameters_default.php

CSharp Default Parameter Value

🎯 한 줄 통찰 (One-line insight)

The = default-value syntax (string country = "Norway") is identical to C++'s default parameter syntax already covered in Topic_CPP — the strict positional-matching rule from the previous chapter ("same number of arguments as parameters") gets its FIRST exception here: calling MyMethod() with zero arguments is now valid specifically because the parameter itself supplies a fallback, making "optional parameter" and "default parameter value" two names for the exact same mechanism. [S1]

🧠 핵심 개념 (Core concepts)

  • Default parameter value — assigned with = in the method signature: static void MyMethod(string country = "Norway"). [S1]
  • "Optional parameter" — the tutorial's alternate name for a parameter with a default value; calling the method WITHOUT that argument is now valid (breaking the prior chapter's strict count-matching rule). [S1]
  • Overriding the default — passing an explicit argument still overrides the default value normally. [S1]

📖 세부 내용 (Details)

  • static void MyMethod(string country = "Norway") { Console.WriteLine(country); } ... MyMethod("Sweden"); MyMethod("India"); MyMethod(); MyMethod("USA"); → outputs Sweden, India, Norway (default used when no argument given), USA. [S1]

⚖️ 모순 및 업데이트 (Contradictions & updates)

  • 인자 개수 일치 규칙의 첫 예외: Method Parameters 챕터에서 확립된 "인자 개수가 매개변수 개수와 정확히 일치해야 한다"는 규칙이, 기본값이 있는 매개변수에 한해 예외적으로 완화된다는 점이 확인됨 — MyMethod();처럼 인자 없이 호출해도 유효함. [S1]
  • C++의 기본 매개변수 문법과 동일: = 기호로 기본값을 지정하는 문법이 Topic_CPP의 Default Parameters 챕터와 차이가 없다는 점이 확인됨. [S1]

🛠️ 적용 사례 (Applied in summary)

country 매개변수에 기본값 "Norway"를 지정한 뒤, 인자를 주거나 주지 않고 네 번 호출하는 예제가 원문에서 직접 실전 활용 사례로 제시됨. [S1]

💻 코드 패턴 (Code patterns)

Default parameter value — makes the argument optional (C#):

static void MyMethod(string country = "Norway")
{
    Console.WriteLine(country);
}

static void Main(string[] args)
{
    MyMethod("Sweden"); // Sweden
    MyMethod();          // Norway (default used)
    MyMethod("USA");    // USA
}

검증 상태 및 신뢰도

  • 상태: draft
  • 검증 단계: conceptual
  • 출처 신뢰도: B (W3Schools — widely used educational reference, not a primary standards body)
  • 신뢰 점수: 0.83
  • 중복 검사 결과: 신규 생성 (New discovery)

🔗 지식 그래프 (Knowledge Graph)

📚 출처 (Sources)

📝 변경 이력 (Change history)

  • 2026-07-04: Initial draft synthesized from the W3Schools "C# Default Parameter Value" page (Astra wiki-curation, P-Reinforce v3.1 format).