public static string Merge(string textOriginal, string textLeft, string textRight, bool makeLeftWin = false) { var mergedResult = Diff.Diff3Merge( textLeft.Split('\n'), textOriginal.Split('\n'), textRight.Split('\n'), true); var mergedText = new StringBuilder(); foreach (var item in mergedResult) { if (item is Diff.MergeConflictResultBlock) { if (makeLeftWin) { var part = (item as Diff.MergeConflictResultBlock).LeftLines; mergedText.AppendLine(string.Join("\n", part)); } else { throw new Exception("Merge conflict"); } } else { var part = (item as Diff.MergeOKResultBlock).ContentLines; mergedText.AppendLine(string.Join("\n", part)); } } return(mergedText.ToString()); }