I did roughly the same thing in C# 1.1: write a static helper method to
which you pass the row, the column name, and the default value, and it
returns the value. I had one for each primitive type, including one for
strings.
In C# 2.0 there are nullable types, but I'm not sure how they are at
mediating between DbNull and null.
Martin Carpella - 06 Apr 2006 07:18 GMT
> In C# 2.0 there are nullable types, but I'm not sure how they are at
> mediating between DbNull and null.
In C# 2.0 you can use the "as" operator in conjunction with nullable
types, e.g.:
IDataReader r = ...;
int? val = r["MyColumn"] as int?;
This will gracefully handle the case that r["MyColumn"] contains a
DbNull.
Best regards,
Martin
Web learner - 06 Apr 2006 19:26 GMT
For a beginner like me,the whole scenario is overwhelmingly confusing. It is
hard to figure out what is legacy and what is cutting-edge elegant methods.
Can someone be kind to point out to latest tutorial material on this topic?
Please refer to my original messsage.
Thanks !
"Bruce Wood" <brucewood@canada.com> wrote in message .
>I did roughly the same thing in C# 1.1: write a static helper method to
> which you pass the row, the column name, and the default value, and it
[quoted text clipped - 3 lines]
> In C# 2.0 there are nullable types, but I'm not sure how they are at
> mediating between DbNull and null.