String casts in .NET

后端 未结 5 1349
醉话见心
醉话见心 2021-02-15 02:30

Why is there so may ways to convert to a string in .net? The ways I have seen are .ToString, Convert.ToString() and (string). What is the Difference.

5条回答
  •  一生所求
    2021-02-15 03:10

    Convert.ToString() will return an empty string if the object is null .ToString and (String) will throw an exception. Convert.ToString will internally call .ToString() if the value is null it will return an empty String.

提交回复
热议问题