Here: We compute the product of 100 and 5. The number 100 is a constant. The value 5 was determined at program runtime.
Note: Because one value was not known at compile-time, the C# compiler cannot compute the product of the operands statically.
C# program that multiplies numbers
static void Main()
// Use a constant local and a dynamically
// ... determined integer as operands.
const int operand1 = 100;
int operand2 = int.Parse("5");
// Compute the product and store it in a local variable.
int product = operand1 * operand2;
// You can check the value of a multiple expression in an if-statement.
if ((operand1 * operand2) == 500)
// You can multiply a number against itself.
operand2 *= 2;
Console.WriteLine(operand2); // Now equal to 10 not 5.
Table. Next we write a multiplication table program. It uses two nested for-loops. The numbers we loop over are in the range 1 to 9.
Info: In the innermost statement, we use the multiplication operator and then use a ToString format pattern.