Skip to content

Commit dec21dd

Browse files
authored
Use ToDouble() instead of ToInt32() for double type variable
The variable num2 is of type double, but the code was using ToInt32() to convert it. This can lead to potential loss of precision or rounding errors. The method should be updated to use ToDouble() to properly handle the double type.
1 parent 7917e3e commit dec21dd

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

docs/get-started/csharp/tutorial-console.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -395,7 +395,7 @@ Let's change the code to handle this error. In *Program.cs*, replace the code fo
395395
while (num2 == 0)
396396
{
397397
Console.WriteLine("Enter a non-zero divisor: ");
398-
num2 = Convert.ToInt32(Console.ReadLine());
398+
num2 = Convert.ToDouble(Console.ReadLine());
399399
}
400400
Console.WriteLine($"Your result: {num1} / {num2} = " + (num1 / num2));
401401
break;

0 commit comments

Comments
 (0)