Reputation: 2443
Am I blind? Where is the local variable?
1>d:\path\Start.cs(99,11,99,20): error CS0844: Cannot use local variable '_mainAssy' before it is declared. The declaration of the local variable hides the field
Also same error lines 100, 102, 105.
private AssyFile _mainAssy = null;
private AssyFile MainAssy()
{
if (_mainAssy != null) // this is line 99.
return _mainAssy;
try
{
_mainAssy = new AssyFile(Application.ActiveDocument as AssemblyDocument);
}
catch
{
_mainAssy = documents.CreateAssy();
}
returrn _mainAssy;
}
EDIT: added missing try and catch statements. (Before removed to try to resolve bug. Current question is: Why does mispelling 'return' cause this compiler message?
Upvotes: 2
Views: 365
Reputation: 292465
The problem is here:
returrn _mainAssy;
Because you misspelled return
, the compiler doesn't recognize the keyword. So it thinks returrn
is a type, and returrn _mainAssy
is the declaration for a variable _mainAssy
of type returrn
...
Upvotes: 3