Home > Articles > Details

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

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. 


If you log in, you will be notified when someone leaves a comment.

Other users would like to know if this solution helped you.

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

© 2022 - ErnesTech - Privacy