On start, I want my program to check services status from a list in an array and then add them to two new textboxs:
    public string[] wantedServices = { "MSSQL$SQL", "SQLBrowser" };
    public TextBox[] txtserviceStatus = new TextBox[2];
    //Gets Service Status On Load
    public void StartServiceStatus()
    {
        int i = 0;
        ServiceController[] services = ServiceController.GetServices()
                      .Where(svc => wantedServices.Contains(svc.ServiceName))
                      .ToArray();
        foreach (ServiceController sc in services)
        {
            txtserviceStatus[i].Text = sc.Status.ToString();
            this.Controls.Add(txtserviceStatus[i]);
            txtserviceStatus[i].Left = 0;
            txtserviceStatus[i].Top = (i + 1) * 20;
            i++;
        }
    }
When I step through the code, it only does the first line and doesn't break the rest within the foreach loop
Any advice would be greatly appreciated as I am still new to this and want to achieve 'good code'
Many Thanks
 
     
    