# CodeBuilder class

Namespace: [Grasshopper2.Expressions](https://developer.rhino3d.com/api/gh2/namespace/grasshopper2.expressions.md) · Assembly: [Grasshopper2](https://developer.rhino3d.com/api/gh2/assembly/grasshopper2.md)

```cs
public sealed class CodeBuilder
```

A string builder for composing code-like strings.

## Constructors

- [CodeBuilder](https://developer.rhino3d.com/api/gh2/type/grasshopper2.expressions.codebuilder/ctor.md): (3 overloads) Create an empty string builder.

## Properties

- [Depth](https://developer.rhino3d.com/api/gh2/type/grasshopper2.expressions.codebuilder/depth.md): Gets the indentation depth of the builder.
- [DepthText](https://developer.rhino3d.com/api/gh2/type/grasshopper2.expressions.codebuilder/depthtext.md): Gets or sets the string to use for indenting.
- [Length](https://developer.rhino3d.com/api/gh2/type/grasshopper2.expressions.codebuilder/length.md): Gets the current length of the builder.
- [Prefix](https://developer.rhino3d.com/api/gh2/type/grasshopper2.expressions.codebuilder/prefix.md): Gets the current indentation prefix string.

## Methods

- [Add](https://developer.rhino3d.com/api/gh2/type/grasshopper2.expressions.codebuilder/add.md): (2 overloads) Add a formatted string to the current line.
- [AddLine](https://developer.rhino3d.com/api/gh2/type/grasshopper2.expressions.codebuilder/addline.md): (3 overloads) Add a blank line.
- [Cs](https://developer.rhino3d.com/api/gh2/type/grasshopper2.expressions.codebuilder/cs.md): (2 overloads, static) Create a C# constructor statement.
- [EnsureNewLine](https://developer.rhino3d.com/api/gh2/type/grasshopper2.expressions.codebuilder/ensurenewline.md): Make sure that the current insertion location is at the start of a new line.
- [Indent](https://developer.rhino3d.com/api/gh2/type/grasshopper2.expressions.codebuilder/indent.md): (3 overloads) Gets a disposable indentation object.
- [Scope](https://developer.rhino3d.com/api/gh2/type/grasshopper2.expressions.codebuilder/scope.md): Gets a disposable curly brace scope object.
- [ToString](https://developer.rhino3d.com/api/gh2/type/grasshopper2.expressions.codebuilder/tostring.md): Return the code string.
