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

preview_player
Показать описание
Link for all dot net and sql server video tutorial playlists

Link for slides, code samples and text version of the video

Healthy diet is very important both for the body and mind. If you like Aarvi Kitchen recipes, please support by sharing, subscribing and liking our YouTube channel. Hope you can help.

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);
}
}
}
}
Рекомендации по теме
Комментарии
Автор

what if i want to throw a FormatException rather than customizing error message

chomuekez
Автор

Thank very much! I's really helpful!

VoTinhThuong
Автор

Hi Venkat
what is difference between IEnumerable<T>, IList<T>, ICollection<T>, IQueryable<T>  where exact use one another one

mageshwarank
Автор

thank you, I would like to know if there are ay other ways to do the user validation

ahmadhussaini
Автор

Hi Venkat,

  Can you please give an ans which has been asked in an interview. How to improve the performance of the website in .Net

KarthikeyaLovesMihira
Автор

Sir, I have not faced any Interviews or not even given any written test, but I got a question on which you may record a video (if you wish) : How to create chainable methods? e.g. In LINQ we can do something like this : students.Where(s => s.Name == "John").Select(s =>s)

Vishal
Автор

Tanks a lot Mr venkat. Y ou Have thé n'est vidéo programing tutu un y ou tube. M god protégé y ou.

segorbejose
Автор

Hi Venkat,
Your videos are really helpful.
Can you record tutorials for WPF and silverlight as well?
Thanks

nehawanjari
Автор

Hello Venkat, can you please start making videos on WPF technologies. Thank you :) 

Rembala