[351] - Local Delegate Vairable Not Initialised Error


The following code give an error that the local variable 'harvest' is not
initialised. Am I missing something or is this an incorrect error?

// This is sitting inside a windows form.
public void Foo()
{
List result = new List(); Action]]> harvest =
delegate(Control obj)
{
if (Bar(obj))
{
result.Add(obj);
}
else
{
foreach (Control child in obj.Controls)
{
// Local variable 'harvest' might not be initialised before
accessing.
harvest(child);
}
}
};

harvest(this);
}

Thanks

Sean


2 comments
Comment actions Permalink

You example is not compilable

--
Eugene Pasynkov
Developer
JetBrains, Inc
http://www.jetbrains.com
"Develop with pleasure!"
"Sean Kearon" <no@spam.org> wrote in message
news:40d4dfe5123178c9313480e0cb76@news.jetbrains.com...
>

The following code give an error that the local variable 'harvest' is not
initialised. Am I missing something or is this an incorrect error?

>

// This is sitting inside a windows form.
public void Foo()
{
List<Control> result = new List<Control>();
Action<Control> harvest =
delegate(Control obj)
{
if (Bar(obj))
{
result.Add(obj);
}
else
{
foreach (Control child in obj.Controls)
{
// Local variable 'harvest' might not be initialised before
accessing.
harvest(child);
}
}
};

>

harvest(this);
}

>

Thanks

>

Sean

>



0
Comment actions Permalink

Thanks Eugene.....this was also answered in the EAP group, but I missed the
part about non-compilation and assumed that the error highlight was due to
R#. Sorry for the time waste!

Cheers

Sean


0

Please sign in to leave a comment.