---
title: "Show base lines in a merge conflict in C#"
url: https://recursiveai.org/onediff/cookbook/include-base-text-in-merge-conflicts/
description: "Use diff3 conflict markers in C# to show the original lines alongside both edits. Run the OneDiff example and see where the base appears."
version: "1.0.1"
---

# Show base lines in a merge conflict in C#

**OneDiff** is a free, open-source diff library for .NET from Recursive AI. MIT or Apache-2.0, no native dependencies.

[NuGet](https://www.nuget.org/packages/RecursiveAI.OneDiff) · [GitHub](https://github.com/recursive-ai-oss/onediff-csharp) · [Docs](https://recursiveai.org/onediff/docs/) · [Download example (.zip)](https://recursiveai.org/onediff/cookbook/include-base-text-in-merge-conflicts/include-base-text-in-merge-conflicts.zip)

`Diff3` shows the shared original, or base, alongside both edits.

```shell
dotnet add package RecursiveAI.OneDiff
```

Requires [.NET 10](https://dotnet.microsoft.com/download/dotnet/10.0) (net10.0); .NET 9 and earlier aren’t supported.

Pass the unedited version first.

```csharp
using OneDiff;
using OneDiff.Merge;
Console.Write(Diff.Merge(
    baseText: "port=80\n",
    ours: "port=8080\n",
    theirs: "port=443\n",
    new() { Style = ConflictStyle.Diff3 }
).Text);
```

Unzip [the example](https://recursiveai.org/onediff/cookbook/include-base-text-in-merge-conflicts/include-base-text-in-merge-conflicts.zip), then `dotnet run`.

Prints:

```text
<<<<<<< ours
port=8080
||||||| base
port=80
=======
port=443
>>>>>>> theirs
```

The original setting, `port=80`, appears after `||||||| base`. If the edits merge cleanly, there are no conflict markers or base sections; keep the merge result and check its `HasConflicts` before saving the text as a finished merge.

## Variations

**Label the three versions.** Replace the settings argument in the snippet with this one to make the branch names visible in the conflict:

```csharp
new MergeSettings
{
    Style = ConflictStyle.Diff3,
    OursLabel = "development",
    BaseLabel = "original",
    TheirsLabel = "release"
}
```

**Move identical edge lines outside the conflict.** Both styles print the base. Replace the settings argument with this one; it prints the same result for the single-line example.

```csharp
new MergeSettings { Style = ConflictStyle.ZDiff3 }
```

## Related recipes

- [Merge independent text edits](https://recursiveai.org/onediff/cookbook/three-way-text-merge/)
- [Read three-way merge conflicts as structured data](https://recursiveai.org/onediff/cookbook/merge-text-without-conflict-markers/)

## The short answer

Call `Diff.Merge(baseText, ours, theirs, new MergeSettings { Style = ConflictStyle.Diff3 })` and display `result.Text`. The `||||||| base` marker starts the original lines for that conflict; `=======` ends the base section and starts the other side. The two sides and the base are all shown together, so a reviewer can compare each edit to what was there before.

## How do you view the original lines in a merge conflict?

In the example, seeing only `port=8080` and `port=443` tells you the edits differ. Seeing `port=80` as well tells you that neither side kept the original. The base section shows the original range for that conflict, not the entire original file. Keep the full base separately if the reviewer needs more context.

Read the sections in order: ours, base, then theirs. The labels describe the order in which your application submitted the inputs. If those files came from named branches, use the label settings to identify the actual branches instead of asking readers to remember which one is “ours.”

## What is the difference between diff3 and zdiff3?

[OneDiff’s conflict styles](https://recursiveai.org/onediff/docs/merge/#conflict-styles) control how conflicts appear. The default `Merge` style shows just ours and theirs. `Diff3` shows the base as a third section without narrowing the conflict. `ZDiff3` also shows the base, but moves lines that both sides share at the start or end of a conflict outside the markers; the base section itself stays whole.

Use `Diff3` when you want the full conflicting ranges visible together. Use `ZDiff3` when repeating the same opening or closing lines makes the edits harder to spot. Neither style selects a winning edit. `HasConflicts` still tells you whether the result needs review, and the marker lines are for the reviewer, not for the application that consumes the final settings file.
