Немного в зависимости от используемой вами версии C# вы можете использовать TryParse
, которая также доступна для int
, float
, et c.:
decimal grossPrice = decimal.TryParse(row.GetCell(10).ToString(), out var val) ?
val : your_default_value; //your_default_value = 0 in your case
или
decimal val = 0;
if (decimal.TryParse(row.GetCell(10).ToString(), out val)
{
//value set
//not needed, but handy for the completeness of this example
}
else
{
//value not set (error; assign default value to val)
//not needed, but handy for the completeness of this example
}