How to check if the number is empty in C-Sharp Asp.Net Core

Question: Is there a way to check if the number is empty in C#? There are so many ways to check for Empty Strings but Can I check if the Integer is Empty?

Login to See the Rest of the Answer

The integer is either 0 or greater than 0. The way you check if the number of Integer is empty is C# is by checking if the Integer Number is 0.

Make sure that you have defined the Data Type of number in your #HTML Form Control like below:

<input type="number" name="myInt" />

This way the Server-Side knows what data type is coming from the Client Side which is the Browser.

I hope this helps. 

Mark said:

The other way is to cast the Integer to a String then check weather that String is empty

Posted On: October 06, 2022 19:00:50 PM

© 2024 - ErnesTech - Privacy
E-Commerce Return Policy