multiply two numbers in csharp

To multiply two numbers in C#, we use the * operator. Here is an example:

main.cs
int num1 = 5;
int num2 = 10;
int result = num1 * num2;
Console.WriteLine("The result is: " + result);
102 chars
5 lines

In this example, we declare two integer variables, num1 and num2, and set their values to 5 and 10, respectively. We then declare a third integer variable, result, and assign it the value of num1 multiplied by num2, which is 50. Finally, we display the result in the console using Console.WriteLine.

You can change the values of num1 and num2 to calculate the multiplication of any two numbers in C#.

gistlibby LogSnag