Welcome toVigges Developer Community-Open, Learning,Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.1k views
in Technique[技术] by (71.8m points)

debugging - Conditional C# breakpoint?

I'm debugging a foreach loop which will iterate well over 1000 times - so I only want a breakpoint within the loop to break for a particular item.

So...

foreach(Employee employee in employees)
{
//DO SOMETHING
//BREAK HERE WHEN employee.Id == '2342'
//DO SOMETHING ELSE
}

Do I have to write an If statement and some dummy code within it and break it that way? That the only way?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
if (employee.Id == '2342') Debugger.Break();

Alternatively, you can set a conditional breakpoint in VS, but from my experience, that is incredibly slow.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to Vigges Developer Community for programmer and developer-Open, Learning and Share
...