Question: I'm trying to populate a class object with values from a database table. The `someObject.Property` field is a nullable int type.

```
someObject.Property = Convert.ToInt32(dbReader["SomeField"]);

```

So, if `SomeField` is `null`, `Convert` will give a `DBNull` error. Is there a specific method I should be using for this?

Answer: 
You could use [`TryParse`](http://msdn.microsoft.com/en-us/library/f02979c7.aspx). This won't specifically check for NULLs but it will tell you whether it is parseable or not which is probably what you really want.

```
bool result = Int32.TryParse(value, out number);

```
```
int someFieldIndex = reader.GetOrdinal("SomeField");
someObject.Property = reader.IsDbNull(someFieldIndex) ? null : (Int32?)reader.GetInt32(someFieldIndex);

```