Expressions

SSharp S# API

DropDown image DropDownHover image Collapse image Expand image CollapseAll image ExpandAll image Copy image CopyHover image

The syntax of expressions is very standard, examples are:

 
X = (y+4)*2;
Y = a[5] + 8;
Z = Math.Sqrt(256);
P = new System.Drawing.Point(3,4);
'this is string' is string

Expressions can be concatenated using the following operators:
 

+, -, *, / ,%, ! , | , & , != , > , < , is

 

Code expression <! program code !> compiles a given code as S# function:

 

a = <! c++; b+=3; return 2; !>;

c=2;

b=5;

f = a();

 

Test.AreEqual(2, f);

Test.AreEqual(3, c);

Test.AreEqual(8, b);

 

 

a = <! return a+b; !>;

Test.AreEqual(19, a([a->9, b->10]));

 
There is also special operator new for creating instances of imported types:

 

b = new TypeName(constructor arguments);