1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Getting Dynamic Input - IO.GetInt

Discussion in 'C#' started by jagu_rita, Jul 25, 2007.

  1. jagu_rita

    jagu_rita New Member

    Joined:
    Jul 21, 2007
    Messages:
    8
    Likes Received:
    0
    Trophy Points:
    0
    :) 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.
     
  2. shabbir

    shabbir Administrator Staff Member

    Joined:
    Jul 12, 2004
    Messages:
    15,283
    Likes Received:
    364
    Trophy Points:
    83
    System.Console.ReadLine
     
  3. jagu_rita

    jagu_rita New Member

    Joined:
    Jul 21, 2007
    Messages:
    8
    Likes Received:
    0
    Trophy Points:
    0
    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.
     
  4. shabbir

    shabbir Administrator Staff Member

    Joined:
    Jul 12, 2004
    Messages:
    15,283
    Likes Received:
    364
    Trophy Points:
    83
    Why you don't want to be using the one method.
     
  5. jagu_rita

    jagu_rita New Member

    Joined:
    Jul 21, 2007
    Messages:
    8
    Likes Received:
    0
    Trophy Points:
    0
    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.
     
  6. shabbir

    shabbir Administrator Staff Member

    Joined:
    Jul 12, 2004
    Messages:
    15,283
    Likes Received:
    364
    Trophy Points:
    83
    One method could be the type casting one. Try a typecasting of an string into an integer and see what happens.
     
  7. jagu_rita

    jagu_rita New Member

    Joined:
    Jul 21, 2007
    Messages:
    8
    Likes Received:
    0
    Trophy Points:
    0
    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());
     
  8. jagu_rita

    jagu_rita New Member

    Joined:
    Jul 21, 2007
    Messages:
    8
    Likes Received:
    0
    Trophy Points:
    0
    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.
     

Share This Page