cancel
Showing results for 
Search instead for 
Did you mean: 

C# code can run without brackets ? {}

Anonymous
Not applicable
Hi guys,

Just wanted to see if there is some kind of document regarding code stages. Want to see if a C# code can run without brackets {}. 

Seen some code without brackets and would like to know which is the approach of inserting code stage/code stage guidelines.
Does the code compile within BP without any brackets like this? {}


E.g 
 { static void Main() {
WriteLine(Sqrt(
3*3 + 4*4)); }
}

can use simply WriteLine(Sqrt(3*3 + 4*4));

Thanks,
Ionut

------------------------------
Cohen
RPA Developer

Romania
------------------------------
4 REPLIES 4

AmiBarrett
Level 12
On a high-level principle, what you're saying is correct. However, since there is no console to write to, WriteLine would not work. What you could do in Blue Prism, is save the result of Sqrt(3*3 + 4*4) to a variable, and make sure that variable is in the code stage outputs.

------------------------------
Ami Barrett
Lead RPA Software Developer
Solai & Cameron
Richardson, TX
------------------------------

Anonymous
Not applicable
Morning and thank you for your answer!

Now I realized that that into the Initialise Page at Global Code tab there is a plethora of code and in the code stage, people were using/calling the methods from this Global Code tab to the Code Stage. Nevertheless the code inside that code stage has no curly brackets {}.

------------------------------
Cohen
RPA Developer

Romania
------------------------------

I think you are confusing Visual Basic with C#.  Many of the VBOs provided with Blue Prism make use of Visual Basic which does not use curly brackets.  You should end up with code errors should you try not to use brackets for C# code.  There is a drop-down on the Code Options page that lets you switch between VB, C# and Visual J#.

------------------------------
Robert Borter
Systems Architect
Virginia Dept of Transportation
America/New_York
------------------------------

bclayton1896
Level 4
It's useful, but maybe inaccurate, to think of a code stage as a method.

For instance this stage:
29537.png

Contains only these lines:
DateTime dtNow = DateTime.Now;
DateTime conversion = DateTime.SpecifyKind(dtNow, DateTimeKind.Utc);
CurrentDateTime = conversion.ToLocalTime();

No brackets.  The code stage has inputs and outputs, and these are basically input parameters and return type.

So the code stage pseudocode would be the method:

private DateTime CurrentDateTime ()
{
  <code above with DateTime return value>
}

------------------------------
Brian Clayton
Lead Developer - C#/Blue Prism RPA
The Auto Club Group
America/Detroit
------------------------------