TIL: How to convert 2-digit year to 4-digit year in C#

from blog Just Some Code, | ↗ original
Today I was working with credit cards and I needed to convert a 2-digit year to a 4-digit one in C#. The first thing that came to my mind was adding 2000 to it. But it didn’t feel right. It wouldn’t be a problem in hundreds of years, though. To convert 2-digit year into a 4-digit year, use the ToFourDigitYear method inside your current culture’s ...