Files
2nd/10_Wiki/Dev/Topic_CSharp/CSharp_Syntax.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

4.8 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-syntax C# Syntax Programming_Language draft conceptual
using System
namespace class Main
C# 문법
B 0.86 2026-07-04 2026-07-04
csharp
programming-language
w3schools
syntax
https://www.w3schools.com/cs/cs_syntax.php

CSharp Syntax

🎯 한 줄 통찰 (One-line insight)

C# mandates that EVERY line of executable code live inside a class — there is no C-style bare top-level int main(), no C++-style free function outside any class — which means C#'s minimal program has a mandatory extra nesting layer (namespaceclassMain method) that neither C nor C++ required, and the tutorial explicitly flags one specific Java-vs-C# difference unprompted: unlike Java, the C# filename does NOT have to match the class name (even though convention usually makes them match anyway). [S1]

🧠 핵심 개념 (Core concepts)

  • using System; — imports the System namespace, enabling unqualified use of its classes (e.g. Console instead of System.Console). [S1]
  • namespace — a container for classes and other namespaces, used to organize code. [S1]
  • class — a container for data and methods; ALL executable C# code must be inside a class, with no exception (unlike C's free-standing main() or C++'s optional free functions). [S1]
  • Curly braces {} — mark the beginning/end of every code block (namespace body, class body, method body). [S1]
  • Main method — the entry point; code inside its braces is what actually executes when the program runs. [S1]
  • Console.WriteLine() — a method of the Console class (part of the System namespace) used to print text; omitting using System; requires the fully-qualified System.Console.WriteLine() instead. [S1]
  • Semicolons mandatory — every C# statement ends with ;. [S1]
  • Case-sensitivityMyClass and myclass are distinct identifiers. [S1]
  • Filename vs. class name — unlike Java (where the public class name MUST match the filename), C# does not enforce this; matching them is convention only, and the saved file must end in .cs. [S1]

📖 세부 내용 (Details)

  • Full annotated example, line by line: using System; (namespace import) → blank line (ignored whitespace, used for readability) → namespace HelloWorld (organizational container) → { (block start) → class Program (mandatory class wrapper) → static void Main(string[] args) (entry point, keywords deferred to later chapters) → Console.WriteLine("Hello World!"); (the actual output statement). [S1]

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

  • 모든 실행 코드가 반드시 class 안에 있어야 함: C는 최상위 함수(int main())를, C++는 클래스 밖의 자유 함수(free function)도 허용했지만, C#은 실행되는 모든 코드 줄이 반드시 class 내부에 있어야 한다는 제약이 명시적으로 확인됨 — namespace→class→Main이라는 필수 3중 중첩 구조. [S1]
  • 파일명과 클래스명 일치가 Java와 달리 강제되지 않음: 원문이 직접 "Unlike Java, the name of the C# file does not have to match the class name"이라고 명시 — Java는 public 클래스명과 파일명이 반드시 일치해야 하는 반면, C#은 관례일 뿐 강제 규칙이 아님이 확인됨. [S1]

🛠️ 적용 사례 (Applied in summary)

이전 챕터(Get Started)에서 등장한 동일한 Hello World 보일러플레이트를 한 줄씩 분해 설명하는 것이 이번 챕터의 실전 활용 사례로 제시됨. [S1]

💻 코드 패턴 (Code patterns)

Minimal C# program structure — namespace/class/Main nesting is mandatory (C#):

using System;
namespace HelloWorld
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine("Hello World!");
        }
    }
}

검증 상태 및 신뢰도

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

🔗 지식 그래프 (Knowledge Graph)

📚 출처 (Sources)

📝 변경 이력 (Change history)

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