Getting Dynamic Input - IO.GetInt

jagu_rita's Avatar
Light Poster
Hai,

Simple Question.What is a another method to get input from user and convert string into integer(Int.Parse )?
If i am not wrong can we use IO.GetInt method?If i use that i couldnt get output.Can you please tell the way to do this?
Is there any possibility to get Dynamic Input?
Please i need some website names to search good C# tutorial.
Your reply would be appreciated.

(I hope i have posted in correct section.If not please move to desired place.)

-Rita.
shabbir's Avatar, Join Date: Jul 2004
Go4Expert Founder
System.Console.ReadLine
jagu_rita's Avatar
Light Poster
Quote:
Originally Posted by shabbir
System.Console.ReadLine
I hope It will be used to get the string value.How can i convert into integer?
I know one method of doing conversion from string to integer.
int i1=int.Parse(Console.ReadLine());

Do we have any other method to convert from string to integer in visual C#?
Thanks for your reply.
shabbir's Avatar, Join Date: Jul 2004
Go4Expert Founder
Why you don't want to be using the one method.
jagu_rita's Avatar
Light Poster
Quote:
Originally Posted by shabbir
Why you don't want to be using the one method.
Not like that.actually I heard in C# we have another method to convert from string to integer.so if you aware about that please tell me.Moreover i have an assignement in that topic.

It will be very helpful for me.And i have searched in the net.but i cant find out which method used to convert string to integer other than Parse?

Thanks.
shabbir's Avatar, Join Date: Jul 2004
Go4Expert Founder
One method could be the type casting one. Try a typecasting of an string into an integer and see what happens.
jagu_rita's Avatar
Light Poster
We can use Convert.ToInt32 method for conversion from string to Integer Number.
Some Examples :
int i1 = Convert.ToInt32(Console.ReadLine());
DateTime i2 = Convert.ToDateTime(Console.ReadLine());
decimal i3 = Convert.ToDecimal(Console.ReadLine());
jagu_rita's Avatar
Light Poster
We can use Convert.ToInt32 method for conversion from string to Integer Number.
Obvisouly We can use Int.Parse Method also.
Convert.ToInt32 is another Method to get input from user.
Some Examples :
int i1 = Convert.ToInt32(Console.ReadLine());
DateTime i2 = Convert.ToDateTime(Console.ReadLine());
decimal i3 = Convert.ToDecimal(Console.ReadLine());

Thanks.