Multiple choice technology programming languages

What is the difference between the S.ToString() and Convert.ToString(S) in the given scenario?

  1. No difference

  2. S.ToString() handles null values

  3. Convert.ToString(S) handles null values

  4. I don't know.

Reveal answer Fill a bubble to check yourself
C Correct answer
Explanation

The key difference is null handling. If S is null, S.ToString() throws a NullReferenceException because you're calling a method on a null reference. Convert.ToString(S) handles null gracefully and returns an empty string or null without throwing an exception. This makes Convert.ToString safer when null values are possible.