+ 1
How to calculate splitted Strings
So Im doing a project but I need to calculate splitted Strings but it's not working, when I input the strings they just calculate themselves instead of each other Can you help !? And before anyone says to search it on the internet, I did . If you have a link just share it, thanks in advance https://code.sololearn.com/caHAzUHZ9h5m/?ref=app
5 ответов
+ 5
int sum = 0;
foreach(var x in splitted)
sum = sum + Int32.Parse(x); //adding each value to previous sum.
Console.WriteLine(sum); // outside loop.
+ 3
Code Bro For multiplication, you should take initial value for sum as 1.
int sum = 1; // note: n*0 = 0 , n+0 = n
+ 2
splitted.Count()
splitted[0].Length
+ 1
Jaya!
I tried it and it worked thanks but what if I wanted to use a different operator, when I tried to multiply it doesn't work , it only works on addition and subtraction
+ 1
OMG can't believe I didn't think of that lol