is there any another shortcut rather than giving all the arrays seperately like below in for each loop
{Numbers(0)+Numbers(1)+Numbers(2)+Numbers(3)+Numbers(4)+Numbers(5)+Numbers(6)}
i assume you sum all the items in the array,
numbers.Sum(function(d) cint(d))
Thanks
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
-
If we are passing the array variable Numbers, then we need for each loop
-
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
- 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
YourArrayVar.Sum(function (x) Convert.ToInt32(x)).ToString–is it LINQ?
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.