<p>For a situation like capturing text incrementally, for example if you were receiving all of the output.write calls when a page was rendering, and those were being appended into a textwriter over a stringbuilder.</p>

<p>Is there a more efficient way to do this? Something that exists in dotnet already preferably? Especially if there's a total size over a hundred k. Maybe something more like an array of pages rather than contiguous memory?</p>

[{'answer_id': 81186, 'author': 'sh_kamalh', 'author_id': 9794, 'author_profile': 'https://Stackoverflow.com/users/9794', 'pm_score': 3, 'selected': True, 'text': '<p>I think StringBuilder is the most efficient way to append text in .net. To be more efficient you can specify the initial size of the StringBuilder when you create it.</p>\n'}, {'answer_id': 83928, 'author': 'Wolfwyrd', 'author_id': 15570, 'author_profile': 'https://Stackoverflow.com/users/15570', 'pm_score': 1, 'selected': False, 'text': "<p>That's as good as it gets. You can use a StringWriter but it's still writing into a StringBuilder</p>\n"}, {'answer_id': 284793, 'author': 'jonsequitur', 'author_id': 23316, 'author_profile': 'https://Stackoverflow.com/users/23316', 'pm_score': 2, 'selected': False, 'text': "<p>It depends on what you're doing with that text.</p>\n\n<p>If the concern is tracing or logging, I'd say your best bet is to use ETW (Event Tracing for Windows). It's a kernel-level tracing facility that's been built into Windows since Windows 2000 and it's much, much faster than doing file I/O.</p>\n\n<p>If you're not using .NET 2.0, you have to do a little win32 API work to use it, and you have to create a provider class that you register on the system. It's a little complicated but worth the effort.</p>\n\n<p>If you're using .NET 3.5, the managed Etw classes can be found in System.Diagnostics.Eventing.</p>\n"}]
['https://Stackoverflow.com/questions/81067', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/6056/']