【发布时间】:2013-12-10 15:24:34
【问题描述】:
我需要创建将多个 Xelement 连接为一个的方法。 我创建了以下方法:
static void DoStuff(string IP, string login, string password, string port)
{
CommonMethods cm = new CommonMethods();
WebClient webClient = new WebClient();
XElement output = null;
try
{
webClient = cm.ConnectCiscoUnityServerWebClient(IP, login, password);
int rowsPerPage = 100;
int pageNumber = 1;
Console.WriteLine("Getting logins from " + IP);
do
{
Console.WriteLine("Downloading " + pageNumber + " page");
string uri = @"https://" + IP + ":" + port + "/vmrest/users?bla&rowsPerPage=" + rowsPerPage + "&pageNumber=" + pageNumber;
Stream stream = webClient.OpenRead(uri);
output = XElement.Load(stream);
pageNumber++;
}
while (output.HasElements);
Console.WriteLine(output);
}
catch (Exception ex)
{
cm.LogErrors(ex.ToString(), System.Reflection.MethodBase.GetCurrentMethod().Name.ToString());
}
}
但在 Do While 循环中,输出被覆盖。您能否提供一些将输出连接成一个的解决方案?
【问题讨论】: