I try to change the background color of a menu, but the program crashed when the menu item is a separator. I try to check to see if there is a separator before I make the change, but I cannot get the checking type to work

PHP Code:
 foreach (ToolStripMenuItem item in items)
            {
                if (!
item is ToolStripSeparator)
                {
                    
item.BackColor color;
                    if (
item.DropDownItems.Count 0)
                    {
                        
SetItemsBackColor(coloritem.DropDownItems);
                    }
                }
            } 
any hint on getting this to work