Category: Code Samples

  • Generating dynamic dates for MySQL test data

    A quickie MySQL tip: I’ve been working on creating a standard testbed of data (more on that someday) for one of our apps, and the issue of dates came up.  Dates can be a problem in test data if they’re being compared to today’s date, i.e. if it matters if the date field represents something […]

  • Converting value types in C# with Parse and TryParse

    Converting values from one type to another in C# is generally pretty straightforward: most objects contain a ToString() method which handles conversion to strings (at least for simple value types), and most value types have a Parse() method to read a string representation of their type. Of course, dealing with invalid inputs can be a […]

  • C#, List.Find() and Predicates

    Because I use this just infrequently enough to have to look it up every time… I’m a huge (ab)user of the .NET generic collection classes, but I hate cluttering code with foreach() loops every time that I need to find an item in a collection. Enter the Find() method, which takes a predicate and does […]