✅ Does it take both types?
in this code:
’’’cs
while (true)
{
Console.Clear();
Console.WriteLine("===== Console Calculator =====");
Console.WriteLine("1. Addition (+)");
Console.WriteLine("2. Subtraction (-)");
Console.WriteLine("3. Multiplication (*)");
Console.WriteLine("4. Division (/)");
Console.WriteLine("5. Exit");
Console.Write("Select an option (1-5): ");
string choice = Console.ReadLine();
if (choice == "5")
{
Console.WriteLine("Exiting... Goodbye!");
break;
}
Console.Write("Enter first number: ");
if (!double.TryParse(Console.ReadLine(), out double num1))
{
Console.WriteLine("Invalid input! Press any key to try again.");
Console.ReadKey();
continue;
}
’’’
the method takes in both normal numbers and decimal numbers ?
8 Replies
Which method? This is just free-form code.
Also, $code
To post C# code type the following:
```cs
// code here
```
Get an example by typing
$codegif
in chat
For longer snippets, use: https://paste.mod.gg/i guess he means TryParse?
anyway i would pass
CultureInfo.InvariantCulture
to TryParse just in case
i don't know if your decimal number is with ,
or with .
Yes it does, but most importantly $tias
If you tried your code with both inputs you'd have a faster answer than anybody here would give, and it's good practice
Sorry idk why I called it a method I ment line (!double.TryParse(Console.ReadLine(), out double num1)) idk why I can’t get the standard layout to show on discord using ’’’ cs ’’’
Oh okay @FusedQyou yea!
It’s `, not ‘.