C
C#6mo ago
Jayde

Im coding my 3D engine called STRATIS and there are two errors.

Im coding my 3D engine called STRATIS and there are two errors. foreach (var tri in meshCube.tris) The "tri" in the code is showing an error for "A local or parameter named "tri" cannot be declared in this scope because that name is used in an enclosing local scope to define a local or paremeter. and the second error is : Triangle triProjected = new Triangle(); // Initialize triTranslated the triProjected cannot be declared for the same reason.
3 Replies
SpReeD
SpReeD6mo ago
So you have to change the name of the variable ¯\_(ツ)_/¯
Jayde
JaydeOP6mo ago
ive tried it just makes the entire thing bug
SpReeD
SpReeD6mo ago
The error is pretty straight-forward, in your scope, which means class in this context, there's already a field or property with that name, so you have the same variable scoped inside a method and the method containing object. The only solution is to rename one of the variables, usually you rename the one with the least scope, hence the one inside the method. Also method scoped variablenames doesn't need to be self-explanatory, so a single char variablename is fine, like in a foreach block.
Want results from more Discord servers?
Add your server