I'm banging my head against the wall trying to work this one out.
I have the code below:
and when I try and compile it, I get this error
Now I thought it was something to do with the scope of the baseVarElement variable within the curly braces so I made it the a method scope by changing the code to:
but I still get the same error.
Where am I going wrong?
All help is greatly appreciated
Kind regards
Ota
I have the code below:
Code:
protected override void OnDragOver(DragEventArgs drgevent)
{
try
{
if (this.GetItem(position) != null)
{
BaseVar baseVarElement = this.GetItem(position);
}
else
{
BaseVar baseVarElement = this.GetGroup(position);
}
if (!object.ReferenceEquals(baseVarElement, this.PrevPosition))
{
}
}
catch (Exception exception)
{
}
}
Visual Studio said:A local variable named 'baseVarElement' cannot be declared in this scope because it would give a different meaning to 'baseVarElement', which is already used in a 'parent or current' scope to denote something else
Now I thought it was something to do with the scope of the baseVarElement variable within the curly braces so I made it the a method scope by changing the code to:
Code:
protected override void OnDragOver(DragEventArgs drgevent)
{
BaseVar baseVarElement;
try
{
if (this.GetItem(position) != null)
{
BaseVar baseVarElement = this.GetItem(position);
}
else
{
BaseVar baseVarElement = this.GetGroup(position);
}
if (!object.ReferenceEquals(baseVarElement, this.PrevPosition))
{
}
}
catch (Exception exception)
{
}
}
Where am I going wrong?
All help is greatly appreciated
Kind regards
Ota