Support us .Net Basics C# SQL ASP.NET Aarvi MVC Slides C# Programs Subscribe Download

Part 5 - Program to check if the user input is a string or an integer

Suggested Videos:
Part 2 - Display database table metadata in asp.net web application
Part 3 - How to bind a computed column to GridView
Part 4 - Subtract the largest even number and smallest odd number in the given array elements



This is straight forward in C#. If you have used TryParse() function then you already know the answer.



using System;
namespace Demo
{
    class Program
    {
        static void Main()
        {
            Console.WriteLine("Please type your input and press Enter key");
            string strInput = Console.ReadLine();

            int result = 0;
            if (int.TryParse(strInput, out result))
            {
                Console.WriteLine("Your input {0} is a number", result);
            }
            else
            {
                Console.WriteLine("Your input {0} is NOT a number", strInput);
            }
        }
    }

}

dot net written test questions answers

No comments:

Post a Comment

It would be great if you can help share these free resources