I am working with SqlXml and the stored procedure that returns a xml rather than raw data. How does one actually read the data when returned is a xml and does not know about
Compared to the speed of getting data from disk both will be effectively as fast as each other.
The two calls aren't equivalent: the version with an indexer returns an object, whereas GetString()
converts the object to a string, throwing an exception if this isn't possible (i.e. the column is DBNull
).
So although GetString()
might be slightly slower, you'll be casting to a string anyway when you use it.
Given all the above I'd use GetString()
.