المساعد الشخصي الرقمي

مشاهدة النسخة كاملة : Which Castring Strategy Is Better?



C# Programming
05-01-2009, 09:51 PM
Good People,

Greetings.

I am trying to figure out which casting method I should use for my application.

1)

double average = (double)value;

or

2)

double average = value as double;

I thought that since objects of type "double" are not nullable; the cast would throw an exception if "as" returned null. What do you think?

Thanks for any advice or information you can provide.

Blitz