Comments on: How to Check if StringBuilder Is Empty https://code-maze.com/csharp-stringbuilder-check-if-empty/ Learn. Code. Succeed. Tue, 21 Dec 2021 11:42:42 +0000 hourly 1 https://wordpress.org/?v=6.7.5 By: Siderite https://code-maze.com/csharp-stringbuilder-check-if-empty/#comment-4766 Wed, 15 Dec 2021 21:17:41 +0000 https://drafts.code-maze.com/?p=60707#comment-4766 StringBuilder caches the string that it’s supposed to create, so subsequent calls to ToString with no modifications to the builder will return the same string without computing it again. But if you Add something, then call ToString the cached string will be destroyed and another string created. Checking to see if a StringBuilder is empty should always use .Length only, which doesn’t need to generate the string.

]]>