# C# Script

This action allows running custom C# code within the robot's virtualized environment.

## **Properties**

![](https://649489153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MSSr3DfBuOYIkk2T9ec%2F-Mfc04eFpvR_2Y4Kai69%2F-MfdXCx6fipS_auzpINz%2Fimage.png?alt=media\&token=e27d8af2-6716-4740-b60d-2c2482258b99)

### **Input**

* **Code**: click on the button ![mceclip1.png](https://649489153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MSSr3DfBuOYIkk2T9ec%2F-MT1yURFFqikzjwbgrEh%2F-MT1yvn3V248fkl9Z74j%2FcustomCode2.png?alt=media\&token=835e30cb-102c-41fa-9793-eb529383dde9) to open the code editor:

![](https://649489153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MSSr3DfBuOYIkk2T9ec%2F-Mfc04eFpvR_2Y4Kai69%2F-MfdXXqeG48ey4gcL6NQ%2Fimage.png?alt=media\&token=fcb7990f-b6d3-4e1d-9971-d3e41614a413)

Click on **Generate Code Starter** to generate the "Hello world!" code.

![](https://649489153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MSSr3DfBuOYIkk2T9ec%2F-Mfc04eFpvR_2Y4Kai69%2F-MfdXRxyiteRM2km-Lg4%2Fimage.png?alt=media\&token=b418956e-b3ec-4b57-b793-31bba4d89243)

Validate your code using the "**Validate Code**" button.&#x20;

If your code is correct, a pop-up message will inform you that "**Source code is valid**".

![](https://649489153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MSSr3DfBuOYIkk2T9ec%2F-Mfc04eFpvR_2Y4Kai69%2F-MfdY9bJ5lLZ4yu7Zo-Z%2Fimage.png?alt=media\&token=1ab40d85-89af-48ad-aad8-3c78ca9c4041)

If your code is NOT correct, another pop-up message will appear, informing the code is not correct and offering suggestions.

In the case below, on line 20, " is expected to close the string *"este numarul total de mesaje*

The error is registered also in the Error List section.

Same situation if the ; is missing on line 19.

![](https://649489153-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MSSr3DfBuOYIkk2T9ec%2F-Mfc04eFpvR_2Y4Kai69%2F-MfdY_fvS9gc7oeKRfdJ%2Fimage.png?alt=media\&token=86281bbf-ce4e-4ad3-bb18-36a466ae7c3b)

* **Method Name**: default value MainMethod

### **Misc**

* **Display Name**: action display name in your implementation project
* **Wait Before**: number milliseconds robot to wait before executing the action.
* **Wait After:** number milliseconds robot to wait until moving to the next action.
* **Abort on Error**: True/False
* **Retry Times**: Specifies the number of times to retry an action if it doesn't end successfully. Default value 0 (no retry); Use -1 if you want to retry indefinitely.&#x20;

## **Use Case**

### **Potential Use Cases**

* Parse a .csv file for master data synchronization between 2 different systems
* Call information from multiple sources in order to build an automation algorithm

### **Examples of Using C# Code**

**Example**

In this example, the robot will generate two files and a directory in the project folder.

Watch the robot in action:

{% embed url="<https://youtu.be/kA0Hm7T5GGI>" %}

You can see how **C# Script** activity is used in an example that incorporates multiple activities. You can check and download the example from here:

{% file src="<https://649489153-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MSSr3DfBuOYIkk2T9ec%2Fuploads%2FkMeI3WMkEOOY6rROVDBc%2FC-Sharp%20example.rar?alt=media&token=854de9df-3a5c-4e2b-b05e-36194eec09bd>" %}
Get Image sample project
{% endfile %}

The article doesn't fully answer your question, or you want to find out more? Ask your question in the comments, on our community forum, or contact our support team or your account manager. Whatever works for you, your question will find its answer soon!
