Advertisement
Gillito

Untitled

Jun 11th, 2015
231
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.63 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.             string str = null;
  15.             using (StreamReader sr = new StreamReader("D:\\New.txt"))
  16.                 str = sr.ReadToEnd();
  17.                 int result = 0;
  18.                 foreach (char ch in str)
  19.                     if (char.IsDigit(ch))
  20.                         result += (int)Char.GetNumericValue(ch);
  21.                 Console.WriteLine(result);
  22.         }
  23.     }
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement