Advertisement
Gillito

Untitled

Jun 10th, 2015
184
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.68 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.IO;
  4. using System.Linq;
  5. using System.Text;
  6. using System.Threading.Tasks;
  7.  
  8. namespace ConsoleApplication42
  9. {
  10.     class Program
  11.     {
  12.         static void Main(string[] args)
  13.         {
  14.             int sum = 0;
  15.             using (StreamReader sr = new StreamReader("D:\\New.txt"))
  16.             {
  17.                 string result = sr.ReadLine();
  18.                 Console.WriteLine(result);
  19.  
  20.                 foreach (char a in result)
  21.                 {
  22.                     if (char.IsDigit(a))
  23.                         sum += a;
  24.                 }
  25.                 Console.WriteLine(sum);
  26.             }
  27.         }
  28.     }
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement