Parsing Text to Objects

Converting objects to a textual representation is one thing, dealing with user (or text file and so on) input and turning it into rich objects is another thing. You’ve already seen a whole set of Parse, TryParse, and Exact variants, but there are a few more things to note.

Sometimes going back and forth between objects and text is not a lossless conversion. In such cases, the framework often provides a format string named R to emit a text representation that will restore the original value when using a Parse method. A good example is floating-point numbers, whose decimal representation is not exact:

image

As you can see from ...

Get C# 4.0 Unleashed now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.