Is there any another shortcut rather than giving all the arrays seperately like below in for each loop

Hi

Here you are passing the value as a sum which is a individual value
So first I would like to suggest that we won’t be in need of For each loop first

  1. If we are passing the array variable Numbers, then we need for each loop

  2. If we want the sum of array values then we can directly use writeline or any activity where you want to pass that sum value
    With this expression

YourArrayVar.Sum(function (x) Convert.ToInt32(x)).ToString

  1. Sometimes there can be some blank values in the array and in that case we need to do a validation before summation like this

Yourarrayvar.Sum(Function (x) If(String.IsNullOrEmpty(x.ToString), 0, x) )

If it’s empty then will pass 0 as value or it will pass the actual Numerical value

Cheers @Bhagyaraj_Digumarthi

1 Like