Explain C# code

Paste C#, LINQ queries and records included, and Vibe explains what each line returns and when the query actually runs.

Batches.cs

Up to 1,500 characters (about 60 lines). Your code is sent to Unvibe and Google Gemini to write the explanation. Don't paste keys or passwords. Common key formats are refused.

Vibe16 lines selected

Press Explain it for the sample, or paste your own code first.

What this C# sample shows

LINQ
Where keeps the batches whose minutes add up to at least minimum, and OrderBy sorts what is left by name. With beta (20 minutes), alpha (10 and 5) and tiny (2) and a minimum of 15, the result is alpha, beta: >= keeps alpha at exactly 15.
records
sealed record TaskBatch(string Name, List<int> Minutes) declares a class from its two values. C# writes the Name and Minutes properties, value equality and a ToString that lists each property, though for the list it prints only the type name, not the numbers.

Good to know

  • batch with { Name = name } returns a new record and leaves the old one alone: renaming alpha to copy gives a second batch, and the original is still named alpha.
  • with copies the reference to the list, not the list. Add 7 minutes to the copy's Minutes and the original changes too: both now total 22.
  • Record equality compares each property with that property's own Equals. Two batches named a that share one list are equal, but with a new list of the same numbers they are not, because a List<int> is only equal to itself.

Watch out: LongBatches returns a query, not a list, and the query runs again every time you loop over it. Add a delta batch of 30 minutes to the source list after calling it and the same result now gives alpha, beta, delta, while a ToList() taken before still holds alpha, beta.

Explain C# code beside your editor

Unvibe is a free app for Mac and Windows. In the app there is no pasting: select code in any app and press Control+U (Ctrl+Alt+U on Windows).