Default value of StringBuilder in C#

CsharpProgrammingServer Side Programming

Use the default operator to get the default value of StringBuilder.

StringBuilder str = default(StringBuilder);

Above, we have used the default keywords to get the default value.

Let us see the complete code −

Example

 Live Demo

using System;
using System.Text;

public class Demo {
   public static void Main() {
      StringBuilder str = default(StringBuilder);
      Console.WriteLine("Default for StringBuilder = "+str);
   }
}

Output

Default for StringBuilder =

The following is the output. It shows a blank space i.e. Null.

Default for StringBuilder = Null
raja
Published on 04-Sep-2018 10:46:05
Advertisements