Beginner
C#
Q34 / 100
What does the as keyword do?
Correct! Well done.
Incorrect.
The correct answer is B) Performs a safe type cast, returning null if the cast fails instead of throwing
B
Correct Answer
Performs a safe type cast, returning null if the cast fails instead of throwing
Explanation
string s = obj as string; returns null if obj is not a string, unlike (string)obj which throws InvalidCastException.
Progress
34/100