I know this may be a little too scary for some of you so I apologize in advance. Take a deep breath and try to imagine that you can't use NHibernate and you're stuck using ADO.NET (circa 2001, did they even have computers back then?).
If you've ever tried to read the value from a column in a datarow, you've probably run into something like this (a quick Google search will bring up page after page of variations):
Wow, that's ugly. What if I have several nullable columns? What if I have a lot of nullable columns? There has to be a better way.
Let's suppose I have a class MyClass (original huh?) and it has a nullable DateTime property and a nullable integer property.
I like a good one line solution. Of course, you really can't cast DBNull.Value (which would be the value of row["ColumnX"] if the column is null in the database) as a nullable int (or DateTime?). (edit: thanks Chris) The cast above is actually failing but casting with "as" doesn't throw an exception and returns a null value which is just what we want.
"as"... you're my hero...*sniff*