﻿---
title: csharp_prefer_braces
description: Add braces to unbraced control-flow bodies. IDE0011. Applied without a compilation. Defaults to `false`
url: https://docs-v3-preview.elastic.dev/reference/modifiers-and-braces/csharp_prefer_braces
---

# csharp_prefer_braces
Add braces to unbraced control-flow bodies. IDE0011. Applied without a compilation.

## Values


| Value            | Notes |
|------------------|-------|
| `false`          |       |
| `true`           |       |
| `when_multiline` |       |

**Default:** `false`

### `csharp_prefer_braces = false`

```ini
csharp_prefer_braces = false
```

<tab-set>
  <tab-item title="Before">
    ```csharp
    namespace N;

    public class Widget
    {
        public string Classify(int n)
        {
            if (n > 0)
                return "positive";
            else if (n < 0)
                return "negative";
            else
                return "zero";
        }
    }
    ```
  </tab-item>

  <tab-item title="After">
    ```csharp
    namespace N;

    public class Widget
    {
        public string Classify(int n)
        {
            if (n > 0)
                return "positive";
            else if (n < 0)
                return "negative";
            else
                return "zero";
        }
    }
    ```
  </tab-item>
</tab-set>


### `csharp_prefer_braces = true`

```ini
csharp_prefer_braces = true
```

<tab-set>
  <tab-item title="Before">
    ```csharp
    namespace N;

    public class Widget
    {
        public string Classify(int n)
        {
            if (n > 0)
                return "positive";
            else if (n < 0)
                return "negative";
            else
                return "zero";
        }
    }
    ```
  </tab-item>

  <tab-item title="After">
    ```csharp
    namespace N;

    public class Widget
    {
        public string Classify(int n)
        {
            if (n > 0)
            {
                return "positive";
            }
            else if (n < 0)
            {
                return "negative";
            }
            else
            {
                return "zero";
            }
        }
    }
    ```
  </tab-item>
</tab-set>


### `csharp_prefer_braces = when_multiline`

```ini
csharp_prefer_braces = when_multiline
```

<tab-set>
  <tab-item title="Before">
    ```csharp
    namespace N;

    public class Widget
    {
        public string Classify(int n)
        {
            if (n > 0)
                return "positive";
            else if (n < 0)
                return "negative";
            else
                return "zero";
        }
    }
    ```
  </tab-item>

  <tab-item title="After">
    ```csharp
    namespace N;

    public class Widget
    {
        public string Classify(int n)
        {
            if (n > 0)
                return "positive";
            else if (n < 0)
                return "negative";
            else
                return "zero";
        }
    }
    ```
  </tab-item>
</tab-set>