我希望有人能告诉我如何从中获取总数
我的列表?我想获得总数,所以我可以实现progress bar
。我以前可以
让他们数数,但无法得到总和。
以下是我目前所处的位置。我想我需要先将dc转换为int?
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);
}
答案 0 :(得分:2)
如何尝试
int domainCnt = Domain.GetCurrentDomain().FindAllDiscoverableDomainControllers().Count;