How to multiply two integers as strings and return the result also as a string in WinForms C#

1 Answer

0 votes
using System.Numerics;

namespace WinFormsApp1
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        static string MultiplyStrings(string num1, string num2)
        {
            // Convert strings to BigInteger for large number handling
            BigInteger n1 = BigInteger.Parse(num1);
            BigInteger n2 = BigInteger.Parse(num2);

            // Perform multiplication
            BigInteger result = n1 * n2;

            // Convert result back to string
            return result.ToString();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            string num1 = "123";
            string num2 = "456";

            MessageBox.Show("Result: " + MultiplyStrings(num1, num2));
        }
    }
}



/*
run:
 
Result: 56088

*/

 



answered Jun 5, 2025 by avibootz
...