Implementing IFormattable To Create Customizable ToString Options in C#

IAmTimCorey February 12, 2024
Video Thumbnail
IAmTimCorey Logo

IAmTimCorey

View Channel

About

My goal is to make your life easier, specifically when it comes to learning software development. I remember what it was like to not know even what questions to ask. In every video I do, I try to answer those questions. You will notice that I don't usually do quick videos. That's because I would rather help you understand rather than just padding my watch percentages. If you want more in-depth training, feel free to head over to my website (https://www.iamtimcorey.com) where I have courses dedicated to C#, SQL, and more.

Video Description

The ToString method allows you to determine what the string representation of your object is going to be. For instance, you might override the ToString method to return a user's full name from a Person model. However, what if you want to allow for multiple different ToString options. DateTime allows this by passing in a formatting string. We can do the same using the IFormattable interface provided by .NET. In this video, we will look at how to implement the IFormattable interface, as well as how to parse complex custom formatting strings. Full Training Courses: https://IAmTimCorey.com Source Code: https://www.iamtimcorey.com/downloads/?code=IFormattable Mailing List: https://signup.iamtimcorey.com/

You May Also Like