+ 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

19th Nov 2022, 8:03 AM
Code Bro
Code Bro - avatar
5 Réponses
+ 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.
19th Nov 2022, 8:31 AM
Jayakrishna 🇮🇳
+ 3
Code Bro For multiplication, you should take initial value for sum as 1. int sum = 1; // note: n*0 = 0 , n+0 = n
19th Nov 2022, 12:02 PM
Jayakrishna 🇮🇳
+ 2
splitted.Count() splitted[0].Length
19th Nov 2022, 8:12 AM
SoloProg
SoloProg - avatar
+ 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
19th Nov 2022, 11:51 AM
Code Bro
Code Bro - avatar
+ 1
OMG can't believe I didn't think of that lol
19th Nov 2022, 12:12 PM
Code Bro
Code Bro - avatar