JetBrains Rider includes a Read–Eval–Print Loop (REPL), which lets you experiment with C# code without compiling it.
To start a new C# Interactive session
- Select a block of code in the editor and press Ctrl+\ or alternatively, press Alt+Enter and then choose Send selection to C# interactive.
JetBrains Rider will start a new interactive session in a new tab of the Run window and send the selected code to this session. If a C# interactive session is already running, the selected code will be appended to this session.
In this case, JetBrains Rider will open an empty interactive session and reset the current C# interactive session if it is already running. You can also clear the current session at any time by clicking Reset on the toolbar. from the menu.
As soon as the C# Interactive is started, you can write any C# expressions and evaluate them by pressing Enter.
All expressions that you execute during the session are recorded in history. To find a previously executed statement, use the Up/Down buttons or click Replay recent commands and choose the one you need.
If your experiments resulted in some useful code, you can create a new scratch file with the full transcript of the session. To do so, click Export transcript to scratch file on the toolbar.
On Windows, JetBrains Rider will automatically detect and use the
csi.exe executable that ships with MSBuild. On Mac OS X and Linux, JetBrains Rider defaults to Mono’s
csharp. In case JetBrains Rider cannot find the correct executable or if you want to use another JetBrains Rider REPL, you can customize the tool path (and arguments) on the page of JetBrains Rider settings (Ctrl+Alt+S).