User753101303 posted
Hi,
Which is correct. If you look at the doc the usual pattern for TryParse is ;
- you pass the value you want to convert and the value that should receive the converted value
- it returns a boolean that tells if the conversion succeeded
You have also an extra ToString.
In this case you are perhaps going through uneedeed hops. Isn't the db side column you are trying to retrieve already a decimal ? Or if you are tyring with dealing with DBNull.Value (which comes from before having support for nullable value types), I would
add my own extension method to hide this and use just nullable types to be able to write maybe something such as :
decimal? amount=sqlReader.Get<decimal?>(1);
Edit: I meant if the db side column is a decimal you could just use :
decimal amount = sqlReader.GetDecimal(1);