To multiply two numbers in C#, we use the * operator. Here is an example:
main.cs102 chars5 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