SHARE
TWEET

Untitled

a guest Aug 20th, 2019 61 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Threading.Tasks;
  9. using System.Windows.Forms;
  10.  
  11. namespace ExtentExercise
  12. {
  13.     public partial class Form1 : Form
  14.     {
  15.         public Form1()
  16.         {
  17.             InitializeComponent();
  18.  
  19.             int[] array = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };
  20.  
  21.  
  22.             List<int> evenNumbers = new List<int>();
  23.             List<int> oddNumbers = new List<int>();
  24.  
  25.             for (int i = 0; i < array.Length; i++)
  26.             {
  27.                 if (array[i] % 2 == 0)
  28.                 {
  29.                     evenNumbers.Add(array[i]);
  30.                 }
  31.                 else
  32.                 {
  33.                     oddNumbers.Add(array[i]);
  34.                 }
  35.             }
  36.             MessageBox.Show("Sum of even numbers = " + evenNumbers.Sum() + Environment.NewLine + "Sum of odd numbers = " + oddNumbers.Sum());
  37.  
  38.  
  39.  
  40.  
  41.  
  42.  
  43.         }
  44.     }
  45. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top