there are many ways to cast/convert object to another by what the difference between those and if there is no difference why there are so many ways to achieve one thing? Isn’t that damage to language?
let’s say object obj to string.
obj.ToString()
obj as string
(string)obj
Convert.ToString(obj)
You are doing different things here:
ToString()method of the object. The object returns a string as it was programmed to.null), no exception will be thrown.objto the typestring, you are telling the compiler thatobjis astring. Ifobjis not a string type, you will get a cast exception.obj.There are these many different ways to get a
stringfrom anobjectbecause each one is different and have subtle differences. Yes, in many cases the returned string will be the same, but this is not guaranteed.