I have a global variable averagel that I am trying to manipulate in a method. The compiler doesn’t have a problem with me setting the value averagel = averagel / (xrestriction * yrestriction); but for some reason it doesn’t like it when I try to use it to set another variable:
inside = (inside + averagel * (xrestriction * yrestriction)) - 2 * (averagel)(suml);
Only on the line where I try to use averagel’s value to set another int does it return the error ‘sqlDataReader.ReaderDemo.averagel’ is a ‘field’ but is used like a ‘type’. I also tried setting an int in the method to the value of averagel and then trying to use that value to set my inside variable but that returned with an error of “The type or namespace name ‘test’ could not be found (are you missing a using directive or an assembly reference?)” and all I did the line before was declare int test=averagel;
Any ideas what could be going on here?
You probably need an asterisk:
You can’t multiply two values in C# like you can in mathematics. E.g.
(averagel)(suml)makes sense in a math equation but you have to writeaveragel * sumlin C#.