c# - Casting vs Converting an object toString, when object really is a string -


This is not really an issue, though I'm curious. When I save a string, a detractor says, it is inserted into the object. When I want to use it, I have to put it into the tooling, as far as I know there are several ways to do this, first

  string name = (string) DataRowObject ["name "]; / Valid since I know that it is a string  

and the other one is:

  string name = Detorobbs ["name"] . ToString ();  

I am interested in what is the difference between the two? Is it more efficient than ever? (It's just a speculation, my head has been implemented by some looping mechanisms in the toostring () method where casting it can be "sharp", although it is just a "gut feeling").

Can anyone clean it for me?

"text">

For two different purposes, the ToString method of any object should represent the string of that object returned. Casting is quite different, and 'key' as the key word makes a conditional, as it has been said. The key word 'as in' is basically saying, "I get a reference to this object, if that object is thus" while toasting says "I get string representation of that object". The result can be similar in some cases but both should never be interchangeable, because as I said, they exist for various purposes. If you want to cast your desire then you should always use an artist, toasting.


Comments

Popular posts from this blog

c# - ListView onScroll event -

PHP - get image from byte array -

Linux Terminal Problem with Non-Canonical Terminal I/O app -