﻿---
title: csharp_style_expression_bodied_operators
description: Convert eligible block-bodied operators. IDE0023/IDE0024. Defaults to `false`
url: https://docs-v3-preview.elastic.dev/reference/expression-bodies/csharp_style_expression_bodied_operators
---

# csharp_style_expression_bodied_operators
Convert eligible block-bodied operators. IDE0023/IDE0024.

## Values


| Value                 | Notes |
|-----------------------|-------|
| `false`               |       |
| `true`                |       |
| `when_on_single_line` |       |

**Default:** `false`

### `csharp_style_expression_bodied_operators = false`

```ini
csharp_style_expression_bodied_operators = false
```

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

    public class Widget
    {
        public int Value { get; }

        public Widget(int value) { Value = value; }

        public static Widget operator+(Widget a, Widget b) { return new Widget(a.Value + b.Value); }
    }
    ```
  </tab-item>

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

    public class Widget
    {
        public int Value { get; }

        public Widget(int value) { Value = value; }

        public static Widget operator +(Widget a, Widget b) { return new Widget(a.Value + b.Value); }
    }
    ```
  </tab-item>
</tab-set>


### `csharp_style_expression_bodied_operators = true`

```ini
csharp_style_expression_bodied_operators = true
```

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

    public class Widget
    {
        public int Value { get; }

        public Widget(int value) { Value = value; }

        public static Widget operator +(Widget a, Widget b) { return new Widget(a.Value + b.Value); }
    }
    ```
  </tab-item>

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

    public class Widget
    {
        public int Value { get; }

        public Widget(int value) { Value = value; }

        public static Widget operator +(Widget a, Widget b) => new Widget(a.Value + b.Value);
    }
    ```
  </tab-item>
</tab-set>


### `csharp_style_expression_bodied_operators = when_on_single_line`

```ini
csharp_style_expression_bodied_operators = when_on_single_line
```

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

    public class Widget
    {
        public int Value { get; }

        public Widget(int value) { Value = value; }

        public static Widget operator +(Widget a, Widget b) { return new Widget(a.Value + b.Value); }
    }
    ```
  </tab-item>

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

    public class Widget
    {
        public int Value { get; }

        public Widget(int value) { Value = value; }

        public static Widget operator +(Widget a, Widget b) => new Widget(a.Value + b.Value);
    }
    ```
  </tab-item>
</tab-set>