0
C# code error
I have the following piece of code: using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace SoloLearn { class Program { static void Main(string[] args) { const double pi = 3.14; double radius; radius=Convert.ToDouble(Console.ReadLine()); Console.WriteLine(pi*(radius**2)); } } } When I run it, it shows up error CS0193 for line 16 (the Console.WriteLine...). It says that 'the * or -> operator must be applied to a pointer'. Two questions: what exactly IS a pointer, and why does this error show up (and how do I solve it?). Thanks in advance
7 Answers
+ 2
So is ** not a viable operator in C#?
+ 1
Try it this way:
Console.WriteLine(pi*(radius*radius));
+ 1
Or, you have to use Math.Pow() like this
"Math.Pow(radius, 2)"
+ 1
Thank you!
0
Thank you, it worked! Is it possible for me to know why that error occurs?
0
That's because you can't square a number with **