Skip to main content
added 62 characters in body
Source Link
janos
  • 113.1k
  • 15
  • 154
  • 396

Managed to get rid of some lines of code..You can write the equivalent shorter, using the ternary operator ?: and decimal.tryParse, like this:

private decimal ConvertStringToDecimal(string decimalString, decimal defaultReturnValue)
{
    decimal value = decimal.TryParse(decimalString, out value) ? value : defaultReturnValue;
    return value;
}

Managed to get rid of some lines of code..

private decimal ConvertStringToDecimal(string decimalString, decimal defaultReturnValue)
{
    decimal value = decimal.TryParse(decimalString, out value) ? value : defaultReturnValue;
    return value;
}

You can write the equivalent shorter, using the ternary operator ?: and decimal.tryParse, like this:

private decimal ConvertStringToDecimal(string decimalString, decimal defaultReturnValue)
{
    decimal value = decimal.TryParse(decimalString, out value) ? value : defaultReturnValue;
    return value;
}
Source Link
SiD
  • 597
  • 2
  • 8

Managed to get rid of some lines of code..

private decimal ConvertStringToDecimal(string decimalString, decimal defaultReturnValue)
{
    decimal value = decimal.TryParse(decimalString, out value) ? value : defaultReturnValue;
    return value;
}