new to C# and hit this compile error when attempting to use the Round method for the first time. Any ideas? Thanks:
private void totalPoundsTextBox_TextChanged(object sender, TextChangedEventArgs e)
{
TextBox textBox = textBoxes[1];
decimal numericValue = textBoxNumberCheck(textBox, 0M, 22046M,false);
if (numericValue >= 0)
***weight.Kilos = decimal.Round(numericValue / 2.2046M, 2, MidpointRounding.AwayFromZero);***
UpdateBoxValues();
}
I bet you have .Net Core project version prior to 2.0. Decimal.Round()
method was missing in .Net Core prior to 2.0 but is now available. Check this issue for the details.
So you could fix your problem either by upgrading to .Net Core 2.0 or by using Math.Round()
as Sunil suggests.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With