SHARE
TWEET

Untitled

a guest Jan 21st, 2020 65 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.             var fileLines = File.ReadAllLines(filePath);
  2.  
  3.             foreach (var fileRow in fileLines)
  4.             {
  5.                 var numericCharacters = fileRow.Where(c => int.TryParse(c.ToString(), out int number));
  6.  
  7.                 var numbers = numericCharacters.Select(nc => Convert.ToInt32(nc.ToString()));
  8.  
  9.                 var evenNumbers = numbers.Where(n => n % 2 == 0);
  10.  
  11.                 int evenNumberSum = evenNumbers.Sum();
  12.  
  13.                 Console.WriteLine($"{fileRow}   |   {evenNumberSum}");
  14.             }
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