如何将html doc保存到字符串中?

rag*_*gmn 3 c# dom data-conversion

 HtmlDocument doc = new HtmlDocument();
    doc.Load(yourhtml);
    doc.Save(Console.Out);
Run Code Online (Sandbox Code Playgroud)

如何将其保存为字符串而不是Console.Out

I4V*_*I4V 12

string s = doc.DocumentNode.OuterHtml;
Run Code Online (Sandbox Code Playgroud)

要么

var sw = new StringWriter();
doc.Save(sw);
var s = sw.ToString();
Run Code Online (Sandbox Code Playgroud)