Code2Img

C# code screenshots.

How to screenshot C# code properly: what C# snippets actually look like, how auto-detection behaves, the theme that reads best, and the settings that keep the card legible.

What people actually paste

Modern C# is not Java with different keywords: record types, pattern-matching switch expressions with => arms, nullable reference annotations (string?), async Task<T>, LINQ chains (orders.Where(o => o.Total > 0).Select(o => o.Id)), and file-scoped namespaces (namespace App.Services;). Two features fight the renderer. Lambda arrows => appear inside switch arms and LINQ, and $"…{value}…" interpolated strings nest braces in a way that confuses grammars that treat {} as structure.

How auto-detection behaves

C# is rule 8. Three triggers: using System, namespace <word>, and Console.Write. There is a real cross-language collision here: rule 6 (C++) fires on #include or int main(, but a C++ snippet that opens with using namespace std; and no #include matches the C# rule and is rendered as C#. The same happens to a TypeScript snippet containing namespace Foo { — the C# rule comes long before the TS rule (14), so a namespaced TS file is typed as C#. File-scoped namespace App.Services; alone is enough to trigger it, which makes a one-line header the cheapest reliable fix for a misdetected C# card.

Theme that reads best

one-dark-pro for dark: LINQ chains and switch arms produce long runs of punctuation and one-dark-pro keeps punctuation receded, so the lambda bodies stay readable. github-light for light cards that will sit next to .NET docs.

Three tips

Other languages

The same advice, for the languages people paste most.

How Code2Img compares

Feature by feature, against the other code screenshot tools.