Lecture overview -- Keyboard shortcut: 'u'  Previous page: Sample use of IEnumerator and IEnumerable -- Keyboard shortcut: 'p'  Next page: Explicit Interface Member Implementations -- Keyboard shortcut: 'n'  Lecture notes - all slides and notes together  slide -- Keyboard shortcut: 't'  Textbook -- Keyboard shortcut: 'v'  Help page about these notes  Alphabetic index  Course home  Page 17 : 37
Object-oriented Programming in C#
Abstract classes, Interfaces, and Patterns
Sample use of IFormattable

The ToString method prescribed by IFormattable takes two parameters which allow finer control of the string generation than the parameterless method ToString from class Object.

/user/normark/oop-csharp-1/sources/c-sharp/interfaces/reproductions/IFormattable.csA reproduction of the interface IFormattable.

  • The ToString method of IFormattable:

    • The first parameter is typically a single letter formatting string, and the other is an IFormatProvider

    • The IformatProvider can provide culture sensible information.

    • ToString from Object typically calls ToString(null, null)

/user/normark/oop-csharp-1/sources/c-sharp/playing-card/playing-card-to-string/PlayingCard.csThe struct Card that implements IFormattable.

/user/normark/oop-csharp-1/sources/c-sharp/playing-card/playing-card-to-string/Client.csA client of Card which applies formatting of cards.

/user/normark/oop-csharp-1/sources/c-sharp/playing-card/playing-card-to-string/outputOutput from the client program.