james mckay dot net
because there are few things that are less logical than business logic

恭喜发财, now give me some Unicode

Since it is the Chinese New Year, I thought I would say 恭喜发财 to all my Chinese readers and entertain you with a little tidbit of information about C# that you may not be aware of.

You would undoubtedly expect this code to compile correctly:

string HappyNewYear = "恭喜发财";

However, did you know that this will compile correctly as well?

string 恭喜发财 = "Happy New Year";

As an explanation: If the Unicode standard considers something to be a letter, C# allows it in identifiers. This means that Chinese ideographs are all fair game. Unfortunately, however, this is likely to make you rather unpopular in code reviews with any of your co-workers who can’t read Chinese.

Incidentally, 恭喜发财 (pronounced “gong xi fett choi”) translates approximately as “Live long and prosper.” If you are a Trekkie, remember to give a Vulcan salute when you say it.