Custom activity with mutiple outputs "Set" error

Hi Guys , i am creating a custom activity

I tested the with a single output and it was working fine i tested the output in UiPath as well.

As soon as i started to use second output, City.Set(context, result_City) , It is giving me the below error

" string does no contain a definition for ‘Set’ and no accessible extension method ‘Set’ accepting a first argument of type ‘string’ could be found"

What could be the reason

----------------------------------------------------------------------------------------

using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System;
using System.Activities;
using System.ComponentModel;

namespace extractAddressDetails
{
public class Class1 : CodeActivity
{
[Category(“Input”)]
[RequiredArgument]
public InArgument InputString { get; set; }

    [Category("Output")]
    public OutArgument<string> Street { get; set; }

    [Category("Output")]
    public OutArgument<string> City { get; set; }

    
    protected override void Execute(CodeActivityContext context)
    {
        var inString = InputString.Get(context);
        
     //   string inString = "2825 Confederate Drive\nSouth Otselic, NY 13155";
     //   street
        char[] delimiters = new char[] { '\r', '\n' };
        string[] lines = inString.Split(delimiters, StringSplitOptions.RemoveEmptyEntries);
        /*Street Address*/
        string streetAddress = lines[0];
        var result_Street = streetAddress;     

        Street.Set(context, result_Street);         <--- only with this variable outpu working fine


        string cityZipState = lines[1];
        string[] tempCity = cityZipState.Split(',');
        string City = tempCity[0].Trim();         
        string result_City = City;

      City.Set(context, result_City);   <--- giving error

" string does no contain a definition for ‘Set’ and no accessible extension method ‘Set’ accepting a first argument of type ‘string’ could be found

}
}
}

Hello,

You have defined the city variable twice…
You should define it once as
public OutArgument<string> City { get; set; }

Remove below line n try
string City = tempCity[0].Trim();
string result_City = City;

You can make it as
Result_City= tempCity[0].trim()
And now set the result and try.

Thanks,
Meg

Thanks it worked !!!

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