M.G. M.G. - 5 months ago 30
C# Question

constructor do not enter a function C#

i have code. the constructor should enter the

function but when i place breakpoint, it simply do not stop.

what is the problem?

namespace Storehouse {
public partial class MainForm : Form {
public MainForm() {
var a = GetItems(fILEToolStripMenuItem);


public IEnumerable<ToolStripMenuItem> GetItems(ToolStripMenuItem item) {
foreach (ToolStripMenuItem dropDownItem in item.DropDownItems) {
if (dropDownItem.HasDropDownItems) {
foreach (ToolStripMenuItem subItem in GetItems(dropDownItem)) {
yield return subItem;
yield return dropDownItem;




When you're using yield, it means deferred execution, so you need to enumerate your variable a, like this:

var a = GetItems(fILEToolStripMenuItem).ToList();

You can also use ToArray(), whatever, you simply need to enumerate your IEnumerable.