How to calculate sum of number in array of string

want to sum of all number from array without char
Array {10,20,ABC,50,ABC,40}
calculate the addition of only numbers.

1 Like

Hi,

You can use the following query

Assign totalSum = YourArray.Where(Function(x) IsNumeric(x)).Sum(Function(x) Convert.ToDouble(x))

Hi @Sohil_bagwan1
Try this:

Assign inputArray = {"10", "20", "ABC", "50", "ABC", "40"}
Assign totalSum = 0

For Each item In inputArray
    If IsNumeric(item.ToString)
        Assign totalSum = totalSum + CInt(item)
    End If
End For Each

// Display or use the value of totalSum as needed

inputArray is of Data Type System.Object
totalSum is of Data Type System.Int32

Hope it helps!!

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