How do I multiply string? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 5

How do I multiply string?

I have a string of '5,6' as user input, How do i multply to get the answer 5*6= 30

3rd Jul 2020, 12:46 PM
Gouse Basha
Gouse Basha - avatar
6 Answers
+ 12
Ashraf You can do like this string str = Console.ReadLine(); string[] arr = str.Split(","); int mult = 1; foreach(string s in arr) { mult = mult * Convert.ToInt32(s); } Console.WriteLine(mult);
3rd Jul 2020, 1:31 PM
A͢J
A͢J - avatar
+ 6
Ashraf Convert the String into integer array and multiply the values.
3rd Jul 2020, 1:24 PM
A͢J
A͢J - avatar
+ 6
Thanks AJ Anant - C#/Java Challenger bro and alll others
3rd Jul 2020, 1:34 PM
Gouse Basha
Gouse Basha - avatar
+ 3
if your input is a string, you have to parse it to get the integers. just google c# parse string
3rd Jul 2020, 1:13 PM
Bobby Fischer
Bobby Fischer - avatar
+ 2
~ swim ~ can you please show me an example!
3rd Jul 2020, 12:54 PM
Gouse Basha
Gouse Basha - avatar
0
By casting
5th Jul 2020, 7:52 AM
faez tgh
faez tgh - avatar