我已经写了一小段代码来将url拖到列表中。返回一个通用列表并将其传递给另一个方法
public Parse(HtmlDocument doc)
{
List<string> top = new List<string>();
try
{
HtmlNodeCollection node = doc.DocumentNode.SelectNodes("//*[@id='content']/ul/li/a");
if (node != null)
{
foreach (var item in node)
{
Console.WriteLine(item.Attributes["href"].Value);
top.Add(item.Attributes["href"].Value);
}
}
Console.ReadLine();
}
catch(Exception e)
{
Console.WriteLine(e);
}
}
public sub(HtmlDocument doc)
{
}
当我尝试返回列表中的“顶”它来了一个错误“自从‘ConsoleApplication1.go.Parse(HtmlAgilityPack.HtmlDocument)’返回void,返回关键字一定不能跟一个对象表达式“我想知道的问题是,如何返回列表顶部的已压缩的浓缩文件,并将它们传递给方法”sub“?感谢您提供任何建议。
你的函数返回类型在哪里? public returnType FunctionName(HtmlDocument doc){} – kjhf