Files
2nd/10_Wiki/Dev/Topic_CSharp/CSharp_Strings_Access.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.2 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-strings-access C# Access Strings Programming_Language draft conceptual
IndexOf Substring
string indexing C#
C# 문자열 접근
B 0.84 2026-07-04 2026-07-04
csharp
programming-language
w3schools
strings
indexing
https://www.w3schools.com/cs/cs_strings_access.php

CSharp Access Strings

🎯 한 줄 통찰 (One-line insight)

myString[0] reuses the identical square-bracket index syntax from C's raw char arrays and C++'s std::string::operator[], 0-indexed exactly the same way — but C# then layers IndexOf() and Substring() on top as a matched PAIR designed to work together (name.Substring(name.IndexOf("D")) finds a position, then slices from it), a "search then slice" combo pattern this wiki hasn't seen expressed this explicitly in C/C++ (C++'s std::string::find() + substr() do the same job but the tutorial there never demonstrated them chained as a single idiom the way this C# chapter does). [S1]

🧠 핵심 개념 (Core concepts)

  • [] indexing — access a single character by index, 0-based: myString[0] is the first character. [S1]
  • .IndexOf(char) — returns the index position of the FIRST occurrence of a specified character/substring. [S1]
  • .Substring(startIndex) — extracts and returns a NEW string starting from the given index to the end. [S1]
  • Combined idiom: search-then-sliceIndexOf() locates a position, and that position is fed directly into Substring() to extract everything from that point onward (e.g. isolating a last name from a full name). [S1]

📖 세부 내용 (Details)

  • Basic indexing: string myString = "Hello"; Console.WriteLine(myString[0]); // "H" and myString[1]; // "e". [S1]
  • Search: string myString = "Hello"; Console.WriteLine(myString.IndexOf("e")); // 1. [S1]
  • Combined search+slice: string name = "John Doe"; int charPos = name.IndexOf("D"); string lastName = name.Substring(charPos); Console.WriteLine(lastName);"Doe". [S1]

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

  • 대괄호 인덱싱 문법은 C/C++와 동일: myString[0]이 0부터 시작하는 인덱스로 문자에 접근하는 방식이 C 배열, C++의 std::string::operator[]와 차이가 없다는 점이 확인됨. [S1]
  • IndexOf+Substring 조합 관용구가 명시적으로 제시됨: C++도 find()+substr()로 동일한 일을 할 수 있었지만, Topic_CPP의 문자열 챕터에서는 두 메서드를 체이닝하는 관용구가 이렇게 명시적으로 다뤄지지 않았다는 점이 이번 챕터에서 새롭게 확인됨 — "찾고 나서 자르기"라는 하나의 패턴으로 제시됨. [S1]

🛠️ 적용 사례 (Applied in summary)

"John Doe"라는 전체 이름에서 "D"의 위치를 찾아 그 위치부터 Substring()으로 성(lastName)만 추출하는 예제가 원문에서 직접 실전 활용 사례로 제시됨. [S1]

💻 코드 패턴 (Code patterns)

Search-then-slice idiom combining IndexOf() and Substring() (C#):

string name = "John Doe";
int charPos = name.IndexOf("D");        // find position of "D"
string lastName = name.Substring(charPos); // slice from that position -> "Doe"
Console.WriteLine(lastName);

검증 상태 및 신뢰도

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

🔗 지식 그래프 (Knowledge Graph)

📚 출처 (Sources)

📝 변경 이력 (Change history)

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