Articles in the How It Works category

Why StringComparison.Ordinal Is Usually the Right Choice

By Eric — 2 minute read

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 …

Read more...

Unicode Surprises

By Eric — 2 minute read

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 …

Read more...

Office Open XML Deep Dive

By Eric — 2 minute read

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 …

Read more...

ArgumentException Creating an XmlSerializer

By Eric — 2 minute read

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 …

Read more...

Assembly Names

By Eric — 1 minute read

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 …

Read more...

Packing and Alignment

By Eric — 1 minute read

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 …

Read more...