It feels strange to me to be casting null to a type so I wanted to double check that this is the right way to do this:
decimal? d = data.isSpecified ? data.Value : (decimal?)null;


NOTE: I am marking the answer that suggests the method that I personally like the best:
decimal? d = data.isSpecified ? data.Value : default(decimal?)
Yes, that’s fine. Alternatives:
Pick whichever you find most readable.
There’s nothing you can do outside the expression itself, as it’s the type of the expression which the compiler doesn’t know. For example, putting the whole expression in brackets and casting it wouldn’t help.