Here's a little CLR tidbit I picked up today while writing a [RowTest] with MbUnit.
If you want to specify a decimal value in C#, you add the suffix m or M. You can read all about it here. This means you might have something in your code like this:
decimal myBigMoney = 19.95m;
Well, it turns out that 19.95m is not a constant value, it's actually shorthand that the compiler translates to
decimal myBigMoney = new decimal(19.95);
and "decimal" is an alias of the struct System.Decimal. This means that you can't pass the value 19.95m as an argument into an attribute, like this:
(because attribute arguments must be constants!) Luckily, MbUnit 2.4 will implicitly convert your doubles into decimals for you...
Where credit is due: I discovered this here.
10-30-2007 3:18 PM