Help! Argument 'Value' cannot implicitly convert type 'void' to 'object' (C# datatype issue)

Hello,

Using C#, I made a variable with the List datatype under system.collections.generic as shown in the screenshot. I am adding a string to the list, but I got this error. Can someone please help me how I make it working? I have been trying to find a solution over a day now… :frowning:

image

The Add method of List returns void, and you are trying to assign void to a List with your Assign Activity.

Use the “Add To Collection Activity” instead. Or “Add Item to Collection” Activity if you are using latest release.

QQ图片20221102100409

Thank you for the reply. I think the list was not initialised, so I had to set a default value: new List()

image

Yes, in C# or VB.NET for non value types you will need to initialise the variables first.

To add on, for other methods that returns void that is not related to collections, you will need to use the “Invoke Method” Activity. Look up examples on that if you encounter problem trying to invoke methods that returns void.

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.