Link to home
Start Free TrialLog in
Avatar of ajaykothidar
ajaykothidar

asked on

Scanf function in C#

Hi,
i want to write a user interactive program in C#.
How can   i get the program to accept values from user.
What should we use in C# in place of  "Scanf in case of C" or "Cin in case of C++"

rgds
ASKER CERTIFIED SOLUTION
Avatar of sunnycoder
sunnycoder
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Skytzo
Skytzo

I assume that you are making a console program to be able to read in input like this.

The function you are looking for are the console commands.

Example, Console.read(), Console.readline(), and Console.write() .......

Below is an example of Console.Read.  You can search msdn at http://msdn.microsoft.com
for the usage of Console.readline and the other Console commands.

The Console.Readline() returns a string object.  The Console.Read() returns an integer (ordinal) value representative of the ascii value typed in.

int i;
char c;
while (true)
{
 i = Console.Read ();
 if (i == -1) break;
 c = (char) i;
 Console.WriteLine ("Echo: {0}", c);
}
Console.WriteLine ("Done");
return 0;
Avatar of ajaykothidar

ASKER

thanks a lot..
both the url's have lot of info..