Start New Discussion within our Software Development Community

if i want to read some integer what command i must use
how to do i read and save value in multi dimensional array??

urgently needed:-|

maybe this short tutorial will help you. Follow the link near the bottom of the page for other tutorials.

that link is telling how to read from a file I want to know how to read from keyboard.
Like we have have cin command in c++ and scanf in C

If your using a Console app it should be

string strTemp = Console.Readline()

but i said i wanted to read integer tht will read integer as character

int intTemp = Convert.ToInt32(Console.Readline())

i have also found one other way that is
int n= int.Parse(Console.ReadLine());
thanks pal that is great

Crap forgot that he wanted a integer and not a string. :)

no prob it is done now thanks for answering;)

hey these codes are working you can debug and use
int sum = 7;
Console.WriteLine("enter an integer for adding");

int a = int.Parse(Console.ReadLine());

sum += a;


must given input in integer without is it possible in c#?suppose user given input in string how can i manage?

Hi Jeya Rani, welcome to DaniWeb.
First: Don't resurrect old threads.
Start a new thread with your question and refer to this thread with a link, if you want to.
To answer you question, try this:

        /// <summary>
        /// Read an integer from the console
        /// Return 0 if no success(perhaps MaxInt?)
        /// </summary>
        /// <param name="prompt">descriptive message</param>
        /// <returns>an integer</returns>
        public int readInt(string prompt)
            string line = Console.ReadLine();
            int quantity;
            if (int.TryParse(line, out quantity) == false)
                quantity = 0;
            return quantity;
This question has already been answered. Start a new discussion instead.