문제

I hope someone could show me how to get to total numbers of domains from my list? I am trying to get the total so I can implement a progress bar. I was able to get them to count up but unable to just get the sum.

Below is where I am at currently. I am thinking I need to convert dc to int first?

public void findalldomains()
{
    Dictionary<string, List<string>> findD = new Dictionary<string, List<string>>();
    List<int> mydomains = new List<int>();
    Domain domain = Domain.GetCurrentDomain();
    using (domain)
    {
        StringBuilder tempText = new StringBuilder();
        foreach (DomainController dc in
            domain.FindAllDiscoverableDomainControllers())
        {
            tempText.Append(dc.Name);
            tempText.Append(Environment.NewLine);
            listBox1.Items.Add(dc);
            int t = 0;
            int domainCnt = Domain.GetCurrentDomain().FindAllDiscoverableDomainControllers().Count;
            t += domainCnt;
            Console.WriteLine(t);

        }
    }
}
// without loop and list

public static void findalldomains()
{
    int t = 0;
    //  Console.WriteLine(dc.Name);
    int domainCnt = Domain.GetCurrentDomain().FindAllDiscoverableDomainControllers().Count;
    t += domainCnt;
    Console.WriteLine(t);
}
도움이 되었습니까?

해결책

How about trying

int domainCnt = Domain.GetCurrentDomain().FindAllDiscoverableDomainControllers().Count;
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top