Question 1Easy
In C#, how is the keyword string related to System.String?
- string is a value type; String is a class
- string is an alias for System.String
- string is a primitive with no methods
- string is a separate type from System.String
Answer: B. string is an alias for System.String
Explanation
string is the C# keyword that maps to System.String, which is a reference type.
Step-by-step solution
- The compiler maps keyword string.
- It resolves to System.String.
- Both mean the same type.
Why the other options are wrong
- A. Both are the same reference type.
- C. string has all the String methods, such as Length and Substring.
- D. They are literally the same type; the keyword is shorthand.