Visual Studio Development Bookmark and Share   
 index > Visual Studio Debugger > break in List?
 

break in List?

I have code something like this:

departmentList.Foreach
(department =>
{
employeeList.ForEach
(employee=>
{
if (department.Pid.Equals(employee.Pid))
{
var employeeInfo = new EmployeeInfo
{
DeptName = employee.DeptName,
FullName = employee.FullName
};

employeeInfoList.Add(employeeInfo);
found = true;
break; ----------------------> Unresolved jump
}
}
);
}
);

I want to exit through loop once employeeInfo is added in employeeInfoList. But when i add 'break;' , i get this error message 'Unresolved jump'

Does anyone know why?

creativity..
sanjeev40084  Monday, August 31, 2009 3:19 PM
The following is in the help system:

The following rules apply to variable scope in lambda expressions:

  • A variable that is captured will not be garbage-collected until the delegate that references it goes out of scope.

  • Variables introduced within a lambda expression are not visible in the outer method.

  • A lambda expression cannot directly capture a ref or out parameter from an enclosing method.

  • A return statement in a lambda expression does not cause the enclosing method to return.

  • A lambda expression cannot contain a goto statement, break statement, or continue statement whose target is outside the body or in the body of a contained anonymous function.


Here is the link:

http://msdn.microsoft.com/en-us/library/bb397687.aspx

If you really need this type break to occur, you should consider changing from the ForEach extension method to a standard for/each statement.

Hope this helps.


www.insteptech.com ; msmvps.com/blogs/deborahk
We are volunteers and ask only that if we are able to help you, that you mark our reply as your answer. THANKS!
  • Marked As Answer bysanjeev40084 Monday, August 31, 2009 3:29 PM
  •  
DeborahK  Monday, August 31, 2009 3:26 PM
The following is in the help system:

The following rules apply to variable scope in lambda expressions:

  • A variable that is captured will not be garbage-collected until the delegate that references it goes out of scope.

  • Variables introduced within a lambda expression are not visible in the outer method.

  • A lambda expression cannot directly capture a ref or out parameter from an enclosing method.

  • A return statement in a lambda expression does not cause the enclosing method to return.

  • A lambda expression cannot contain a goto statement, break statement, or continue statement whose target is outside the body or in the body of a contained anonymous function.


Here is the link:

http://msdn.microsoft.com/en-us/library/bb397687.aspx

If you really need this type break to occur, you should consider changing from the ForEach extension method to a standard for/each statement.

Hope this helps.


www.insteptech.com ; msmvps.com/blogs/deborahk
We are volunteers and ask only that if we are able to help you, that you mark our reply as your answer. THANKS!
  • Marked As Answer bysanjeev40084 Monday, August 31, 2009 3:29 PM
  •  
DeborahK  Monday, August 31, 2009 3:26 PM

You can use google to search for other answers

Custom Search

More Threads

• Why is VS 2008 IDE so incredibly slow??
• How to not handle an exception?
• Visual Studio Debugger Need Help
• App window doesn't repaint while debugging...
• Debugger seem to time out in VS2005 C#
• Performance issue while pressing F5 in Visual studio 2005
• Execptions swallowed by Visual Studio when "Enable Just my Code" is turned off
• Debugging Features Disappear on VS2008 Silverlight 3.0 Solution
• Stepping through class in different project
• debug.assert doesn't pop up the message when condition is false