Feature:
Immediate .NET Code Execution
Overview
Possible usages for Immediate .NET Code Execution: (This list is not exhaustive!)
- Evaluate complex expressions (like a 'scientific' calculator!).
- Design and test objects, functions and algorithms. No save-to-file is required
until you want to.
- Use the objects of the .NET framework, test their behavior, without worrying about
directories and project files. You can simply paste and run sample code within the
program. Want to check the behavior of a .NET class or function? Just type a test
expression, and you will get the answer.
Program Features:
- Immediate Code Execution for expressions, loose statements and functions.
- Execute code stored in external libraries and code files, or in a loose class
or function declaration.
- Choose the language you prefer: C#, VB.NET, J#, JScript, or add more languages.
- Attach a .NET Debugger to control the execution of your input.
- Save your sessions on your disk, and recall them later with all input history
preserved.
Getting Started
Create a new Immediate Execution session (File | New File, then select Immediate
Execution). The window layout for the session is presented in Figure 1.

Figure 1. Immediate execution session: window layout.
- The Input Type list lets you choose the type of your input. The following
operations are supported:
- Evaluate expressions (see step 2). This type is selected by default.
- Execute function bodies (any procedure that returns a value)
- Execute loose statements.
In this tutorial we will see how to evaluate expressions. Therefore, select
Expression
as the input type.
- Next to the Input Type list is the Input Area,
where you enter expressions to evaluate, and statements to execute. Below
are some examples of expressions you may want to try (C#, VB.NET).
See here for instructions on how to change the language.
2 + 3*Math.Exp(5)
ControlPaint.LightLight(SystemColors.Highlight)
System.IO.Directory.GetDirectories("c:\\windows\\assembly\\gac")
- The Execute button evaluates the instructions
or expressions you enter in the Input Area. Note that the program will attempt to
evaluate the input if you press Enter while typing an expression. The Execute
button has a shortcut key (F9), and the same command can be found under the Run
menu.
- Once you press the Execute button, the program
will display the result, and/or any error encountered. Results are collected in the
history display occupying the top portion of the window.
- To get more
data for the selected result, open the Properties Window (F4). The properties
window will display all available attributes for the result and, when applicable,
show a graphical representation for it.
-
You can reuse some previously entered expressions or statements by double-clicking
the corresponding row. Double-clicking a row will copy the expressions or statements
to the input zone. You can therefore modifiy existing entries, and save a lot of
time instead of retyping entire lines of expressions and statements.
- Advanced users will need to switch to Code View to add custom
variables, functions, and full class
declarations that can be called directly from
the Input Area.
Advanced Users
Custom Variables and Methods
To add code for variables and methods, switch to Code View. Select (ImmediateExecutionSession)
> Declarations in the Fragment List on the left, and add the code
for variables and methods in the text editor. Since these variables and methods
are in the same class than the input to evaluate, you can use them directly without
providing the fully qualified name of the variables and methods (Figure 2a).
> Note: the Declarations fragment uses the namespace and imports provided
in the Build Options properties.
Custom Class Declarations
To add additional namespace/class declarations, switch to Code View. Select
Build Options > UserCode in the Fragment List on the left. Add
the code for new namespaces and classes. Because the UserCode is in a separate unit
from the input code, you have to use the fully qualified name of static methods,
and provide the appropriate namespaces when instanciating a class (Figure 2b).
> Note: the UserCode fragment does not use the imports found
in the Build Options, you must provide namespace imports as if it was a separate
file. See also
this topic.
Figure 2. Filling (top) the Declarations and (bottom) the UserCode fragments.
Configuring Compile Options
In most basic cases, you don't have to do anything
else to execute code as you write it. Simply type in an expression or statements,
press the Execute button, and the program will evaluate and display the result.
However, there are cases where you want to change some settings, such as the language
and referenced files and assemblies.
This topic explains how to change these settings.