Larry,
It should be noted that ToString is not required to output the
information which will allow you to reconstitute an instance from the
results.
The documentation only states:
Return Value
A String that represents the current Object.
There are no guarantees that it can actually be used to create a
specific object.
The reason that a TypeConverter produces a different string is because
its function is to convert one type to another, (strings included), with no
loss of information. From the documentation:
Provides a unified way of converting types of values to other types, as well
as for accessing standard values and subproperties.
This is different from a representation of the object.
Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
-
mv*@spam.guard.caspershouse.com
"Larry Smith" <no_spam@_nospam.comwrote in message
news:eK**************@TK2MSFTNGP05.phx.gbl...
Once you call "ToString()" for an object, how can you then convert the
string back to the original object (assuming you know its type of course)?
Also, why does "ToString()" produce one string and
"TypeConverter.ConvertToString()" produce yet another (e.g., for a
"System.Drawing.Size" object, the former method yields, say, "Width=5,
Height=40" and the latter yields "5, 40"). Thanks.