number or not HELP?

Console.WriteLine("");
string c = Console.ReadLine();
double value;
if (double.TryParse(c, out value))
{
Console.WriteLine("Okey we go back i guess");
}

double newnumber = Convert.ToDouble(Console.ReadLine());
Numbers.Add(newnumber);
Console.WriteLine("");
string c = Console.ReadLine();
double value;
if (double.TryParse(c, out value))
{
Console.WriteLine("Okey we go back i guess");
}

double newnumber = Convert.ToDouble(Console.ReadLine());
Numbers.Add(newnumber);
how to check of the value is a number or not ?
2 Replies
mtreit
mtreitβ€’2y ago
When you call TryParse it will return true if it's a valid number or false if it's not.
eult πŸ‡΅πŸ‡ΈπŸ‡΅πŸ‡Έ

Console.WriteLine("");
string c = Console.ReadLine();
if (int.TryParse(c, out var result))
{
Console.WriteLine($"Thanks for giving me the following number: {result}!");
}
else
{
Console.WriteLine("You didn't give me a valid number :c");
}

Console.WriteLine("");
string c = Console.ReadLine();
if (int.TryParse(c, out var result))
{
Console.WriteLine($"Thanks for giving me the following number: {result}!");
}
else
{
Console.WriteLine("You didn't give me a valid number :c");
}
works πŸ˜‰
Want results from more Discord servers?
Add your server
More Posts
EF Core is throwing DbUpdateConcurrencyException, but only on the production database (MySQL)I am trying to deploy a web application to a server, but I'm running into a weird issue. There is a OnTriggerEnter - When player is in zone for 3 seconds, take damage HelpSorry, I technically posted this a minute ago but due to a radical change in my script, I decided toEF Core Razor Pages and an MSSQL ViewHi Everyone, i am trying to create an Page in Razor for an MSSQL View. I have two tables shown in thSlash Command optional parameter [Answered]Hi, I'm currently working on a poll command where I'm using SelectMenuBuilder and I want for there tReferencing a nuget package without ever restoring itI have a nuget package **A** that only includes native binaries (packaged using a .nuspec file). Inpm won't install a package published just an hour agoWhen I run `npm install multiple-cucumber-html-reporter` I get the following error: ```ps npm ERR! cStackExchange.Redis RedisJSONHey! πŸ‘‹ any idea, how I can use RedisJSON(<https://redis.io/docs/stack/json/>) with StackExchange.Re(Solved) Allow Unsafe Code - VS MacOS [Answered]Hi! I can't seem to find the "Allow unsafe code" checkbox in VS on my mac, despite searching online.debugging issueHello folks, I have a problem I hope I can explain what's happening. When I have break points on cerforce 'normal' standards for parsing decimal numbers from stringI want to force my ASP.NET API to parse numbers as '102.28', currently it throws an error because it