The following nullable decimal code fired Overload Method Error:
decimal? t1 = null;
decimal? t2 = null;
decimal? t3 = null;
decimal res = 0;
decimal tt1 = 0;
decimal tt2 = 0;
decimal tt3 = 0;
if (decimal.TryParse(textBox1.Text, out tt1))
t1 = tt1;
if (decimal.TryParse(textBox2.Text, out tt2))
t2 = tt2;
if (decimal.TryParse(textBox3.Text, out tt3))
t3 = tt3;
res = Math.Abs(t1 + t2 - t3);
textBox4.Text = res.ToString();
The above code suggested calculation between three textBoxes and fourth textBox showing result of them. But the problem is Math.Abs method is not supported for nullable type decimal. How to overcome?. How to overcome means i wants to allow nullable in Math.Abs method by another way.
My guess is that you actually want
Math.Abs(tt1 + tt2 - tt3)anyway.If you actually want
nullto be returned if any of the inputs arenull, then maybe you want something like this: