C# Expression denotes a 'value', where a 'method group' was expected
So I am trying to make a simple calculator and I keep getting this error with a specific line of code.
Here's the code
void Calculate(){
intX1 = Mathf.RoundToInt(Mathf.Sqrt(System.Convert.ToSingle((intB * intB) - (4(intA)(intC) )))); //Error is here
Debug.Log (intX1);
}
I convert the int to float so I can use Mathf.Sqrt and then back to an Int for a final value but I keep getting an error.
error CS0119: Expression denotes a`value' , where a`method group' was expected
Your problem is
(4(intA)(intC) )
You have to include the operators
(4*intA*intC) or (4 *(intA * intC))
depending on what you are trying to do.
Answer by EmHuynh · Feb 28, 2016 at 09:12 PM
Hello, @TexasFunk101.
To multiply, we have to use the *operator. This won't work: int i = (4)(4); // = 8
but this will: int i = (4) * (4); // = 8
.
In your function Calculate, the error is caused by: (4(intA)(intC) )
. To resolve it, just add the *operator. The result is: (4 * (intA) * (intC) )
.
Here is the fixed version of function Calculate:
void Calculate() {
intX1 = Mathf.RoundToInt( Mathf.Sqrt( System.Convert.ToSingle( ( intB * intB ) - ( 4 * ( intA ) * ( intC ) ) ) ) );
Debug.Log( intX1 );
}
Thank you very much I was still thinking in math not in code xD. Thank's very much.