954,529 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

how to read integer value in c#?

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:-|

shadowrider
Newbie Poster
20 posts since Feb 2007
Reputation Points: 10
Solved Threads: 0
 

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

Ancient Dragon
Retired & Loving It
Team Colleague
30,050 posts since Aug 2005
Reputation Points: 5,662
Solved Threads: 2,343
 
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

shadowrider
Newbie Poster
20 posts since Feb 2007
Reputation Points: 10
Solved Threads: 0
 

If your using a Console app it should be

string strTemp = Console.Readline()

blacklocist
Junior Poster in Training
87 posts since Apr 2006
Reputation Points: 10
Solved Threads: 2
 
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

shadowrider
Newbie Poster
20 posts since Feb 2007
Reputation Points: 10
Solved Threads: 0
 

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

campkev
Posting Pro in Training
484 posts since Jul 2005
Reputation Points: 14
Solved Threads: 19
 
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

shadowrider
Newbie Poster
20 posts since Feb 2007
Reputation Points: 10
Solved Threads: 0
 

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

blacklocist
Junior Poster in Training
87 posts since Apr 2006
Reputation Points: 10
Solved Threads: 2
 
Crap forgot that he wanted a integer and not a string. :)




no prob it is done now thanks for answering;)

shadowrider
Newbie Poster
20 posts since Feb 2007
Reputation Points: 10
Solved Threads: 0
 

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;

Console.WriteLine(sum);

adem87
Newbie Poster
20 posts since Aug 2011
Reputation Points: 10
Solved Threads: 0
 
int no=(int)Convert.ToInt32(Console.ReadLine());

this ll also work

sanjeevib
Newbie Poster
1 post since Aug 2011
Reputation Points: 10
Solved Threads: 0
 

This question has already been solved

Post: Markdown Syntax: Formatting Help
You