Solved

Scanf function in C#

Posted on 2003-11-27
4
5,351 Views
Last Modified: 2007-12-19
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
0
Comment
Question by:ajaykothidar
4 Comments
 
LVL 45

Accepted Solution

by:
sunnycoder earned 25 total points
Comment Utility
0
 
LVL 1

Expert Comment

by:Skytzo
Comment Utility
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;
0
 
LVL 10

Expert Comment

by:dkloeck
Comment Utility
0
 

Author Comment

by:ajaykothidar
Comment Utility
thanks a lot..
both the url's have lot of info..
0

Featured Post

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
wefewf 2 42
copyEvens challenge 6 63
countX 22 68
control image tags in a string ? 12 59
This is an explanation of a simple data model to help parse a JSON feed
If you’re thinking to yourself “That description sounds a lot like two people doing the work that one could accomplish,” you’re not alone.
An introduction to basic programming syntax in Java by creating a simple program. Viewers can follow the tutorial as they create their first class in Java. Definitions and explanations about each element are given to help prepare viewers for future …
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now