Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
Sum of digits in a string
//Rextester.Program.Main is the entry point for your code. Don't change it. //Compiler version 4.0.30319.17929 for Microsoft (R) .NET Framework 4.5 using System; using System.Collections.Generic; using System.Linq; using System.Text.RegularExpressions; namespace Rextester { public class Program { public static void Main(string[] args) { //Your code goes here string s = "qwert100ft34"; int sum=0; var x = s.ToCharArray(); Console.WriteLine(x); for( int I=0;I<=x.Length - 1;I++) { if(x[I]>'0' && x[I]<='9') { sum += x[I] -'0'; } } Console.WriteLine(sum); } } }
run
|
edit
|
history
|
help
0
What is the best way to iterate over a Dictionary in C#?
IntNull
Rotate array to the right of a given pivot
Inheritance
ffsfsfsfsfsferwfehtyjrvgjb
First Program
AKASH B AND HIS CODES\\
test linq select
Shalini_CSG_CodeTest
Fórum ➡ Calculate the Sum of Values in List of KeyValuePair<> objects ♦