How to find the even from an array and add only add even number

Hi all,

I have an array of integer and I need to find the even number from that and need to ignore the odd number.
After finding the even number I need to add all the even number in the array.

For example: Input {0,1,2,3,4,5,6,7,8}

Even number:{0,2,4,6,8}

Addition of the even numbers: 20(0+2+4+6+8)

Some body please guide on this.

@ppr
@Yoichi

1 Like

HI,

How about the following?

arrInt.Where(Function(i) i mod 2 =0).Sum()

image

Regards,

What is the data type??

HI,

arrInt is Array of Int32 (Int32[]) type

Regards,

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