Compare C# code online

A small C# console program with renamed variables and a new threshold. Paste your own .cs files to see their differences. Tips for C#

Original
0 lines
Drop to load into original
Changed
0 lines
Drop to load into changed
−0+0
Original
Changed

About this C# comparison

Whether you are comparing two versions of a class, checking an auto-generated file after a tool upgrade, or reviewing a change without opening Visual Studio, a C# diff shows exactly which members and statements changed.

C# syntax colours keep keywords, strings and types easy to read, with the changes marked on top.

What changed in this sample

  • num1, num2 and sum became a, b and result, set to 12 and 18.
  • The Console.WriteLine label changed from “Sum” to “Result”.
  • The if threshold went from 15 to 20, and both messages changed with it.

Tips for comparing C#

Compare generated code
Designer files and generated clients change in bulk. Fold unchanged keeps the result short, and the arrows jump between changes.
Ignore CRLF
Files from Windows use CRLF line endings. Those are never counted as changes, and a note tells you when the two files differ.
Compare project files too
.csproj and app.config files are XML; opening them switches the highlighting to XML.
Undo a replacement
Opening a file over existing text shows an Undo button, so you never lose what was in the pane.

How to compare C# online

  1. Paste the older version into Original and the newer one into Changed, or open a file on each side.
  2. Check that the syntax menu says C#, then pick split or unified view.
  3. Step through the changes with the arrows or Alt ↓, and use Settings for options such as ignoring blank lines.
  4. Save the comparison in your browser, share a link, or download it as a .diff, HTML or PDF.

C# comparison: questions

Can I compare two .cs files?

Yes. Open or drop them onto the panes and C# highlighting is chosen from the extension.

Is my code uploaded?

No. The comparison runs in your browser. Code only leaves your machine if you create a share link.

Can I compare VB.NET as well?

Yes. VB.NET is in the syntax menu, and the VBScript sample shows a VB-style program.