Why StringComparison.Ordinal Is Usually the Right Choice

A question that arose in response to my previous post (about how string comparisons can produce unexpected results when done in a culture-sensitive way) was Which is right, StringComparison.Ordinal or StringComparison.InvariantCulture? The short answer: StringComparison.Ordinal.

There is a good article explaining the differences between the StringComparison enum …

Unicode Surprises

I got a defect from QA today saying that our product was unable to track files in paths containing Unicode characters. I'll admit that I was skeptical. I had just tried that myself the other day and it worked perfectly. Trying it again today also worked perfectly, but the QA …

Office Open XML Deep Dive

Last week I went to San Francisco to take a dive off the deep end into the new XML file formats in Microsoft Office 2007. The training was hosted by MindJet, and presented by Doug Mahugh of Microsoft, and Chris Predeek, a consultant who put together the code samples for …

ArgumentException Creating an XmlSerializer

I ran into a kind of baffling problem. I've got some .NET code that is also accessible to Java via JNI. There are unit tests for the .NET code that all pass. To test the Java to .NET connection, I wrote a few JUnit tests which worked fine when run …

Assembly Names

I always have a hard time keeping straight all the possible ways of getting an assembly's name and what form the various methods return. Here's a little program and its output for a reference.

class Program 
    static void Main(string[] args) 
        Assembly assembly = Assembly.GetExecutingAssembly(); 
        Console.WriteLine("Assembly.ToString()           : {0 …

Packing and Alignment

I've made some effort to understand the differences between the Struct Member Alignment compiler option /Zp, #pragma pack and __declspec(align()) with Microsoft Visual C++ in light of an odd bug that ultimately was caused by inconsistent packing options between compilation units.

/Zp and #pragma pack are equivalent, but /Zp …