TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Mohan S
NA
34
38.9k
Check and ensure int value is only numbers
Nov 6 2015 9:47 AM
Hi Guys,
I need to check, my int values which am giving as input should be only numerical value.
int.Tryparse wont work because am not using a string value.
what is the alternate way to get for int value to be numeric.
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Please enter salary");
int salary = Convert.ToInt32(Console.ReadLine());
******* Need to check the SALARY value to be only numeric value and not equal to null also*********
int Output = UserProgramCode.Bonus(salary);
Console.WriteLine("Output is: {0}", Output);
Console.ReadLine();
}
class UserProgramCode
{
public static int Bonus(int salary)
{
int b = 0;
if (salary < 0)
{
b = -1;
}
else if (salary > 10000 && salary < 15001)
{
b = 1200 + ((salary * 15) / 100);
}
else
{
b = 500 + ((salary * 8) / 100);
}
}
return b;
}
}
Reply
Answers (
3
)
database project
Shell program not executing via web when using server name