CA1806: When a method returns a new instance and the instance is ignored

The official title of the CA1806 analyzer warning is “Do not ignore method results,” but this doesn’t really show up in the list of warnings. Instead of showing this generic message, when CA1806 is triggered, it shows very specific text about what triggered the warning. In this article, I’ll show a few examples of code … Read more

SQL Server – Getting and storing date/time

In this article, I’ll show built-in functions in SQL Server for getting the current datetime and how to get individual parts of the datetime (such as the year). Then show I’ll show how to store datetimes using the four different date/time data types (date, time, datetime2, and datetimeoffset). Getting the current datetime SQL Server has … Read more

C# – How to test that your code can handle another culture’s date format

Let’s say you’re using DateTime.Parse() to convert a date string into a DateTime object. By default, DateTime.Parse() uses CultureInfo.CurrentCulture to figure out the date format. The current culture ultimately comes from your OS settings. So when you run this code on a computer that is using the en-US locale, the current culture will automatically default … Read more