You want your type to be convertible from a string. Which interface should you implement?

The answer to exam 70-483 (Wouter de Kort) is "IFormattable". Explanation in the book: โ€œIFormattable provides functionality to format the value of an object into a string representation ( I agree with this part ). It is also used by the Convert class to do the opposite.

How to Convert can create an object from a string? It doesn't have a FromString (it has a ChangeType, but still). More interesting, how can IFormattable facilitate chaining from a string?

I honestly think the question is invalid, but I want to be sure.

+3


source to share





All Articles