Difficulty: Easy
Correct Answer: A String has a zero-based index.
Explanation:
Introduction / Context:This item focuses on core properties of C# strings: immutability, indexing, and representation.
Given Data / Assumptions:
Concept / Approach:In C#, string is immutable and zero-indexed. You can create new strings via methods, but existing instances do not change in place.
Step-by-Step Solution:
Immutability: statements (a) and (b) are false; methods return new strings instead of modifying the original.Numeric text: (c) is false; any number can be represented as text (e.g.,"123").Indexing: (d) is true — string indexer uses zero-based positions.Representation: (e) is false — strings are System.String, not System.Array, though you can get a char[] copy.Verification / Alternative check:Observe that s.Replace("a","b") leaves s unchanged and returns a new string.
Why Other Options Are Wrong:They contradict immutability or conflate arrays with strings.
Common Pitfalls:Assuming string behaves like a mutable character buffer; use StringBuilder for that.
Final Answer:A String has a zero-based index.
Discussion & Comments