Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

How to make the similar thing to cin >> MyDataType  of C++ ?

Posted on 2006-10-19
3
Medium Priority
?
188 Views
Last Modified: 2010-04-16
In C++, we can do:

CStudent s;
cin >> s;

(the operator >> overloaded)

How to make similar thing in C# ?

Thanks.
0
Comment
Question by:Harry_Kewell
  • 2
3 Comments
 
LVL 20

Expert Comment

by:TheAvenger
ID: 17771935
You would need to write a constructor that gets string as a parameter, read a string from the console and then create the object passing the read string
0
 

Author Comment

by:Harry_Kewell
ID: 17772658
Could you give more detail explanations ? Thanks.
0
 
LVL 20

Accepted Solution

by:
TheAvenger earned 360 total points
ID: 17772671
public class Student {
public Student (string initString)
{
  // Do initialization from the initString
}
}
......
string s = Console.ReadLine ();
Student stud = new Student (s);
0

Featured Post

Ask an Anonymous Question!

Don't feel intimidated by what you don't know. Ask your question anonymously. It's easy! Learn more and upgrade.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction Although it is an old technology, serial ports are still being used by many hardware manufacturers. If you develop applications in C#, Microsoft .NET framework has SerialPort class to communicate with the serial ports.  I needed to…
This article is for Object-Oriented Programming (OOP) beginners. An Interface contains declarations of events, indexers, methods and/or properties. Any class which implements the Interface should provide the concrete implementation for each Inter…
This Micro Tutorial will teach you how to add a cinematic look to any film or video out there. There are very few simple steps that you will follow to do so. This will be demonstrated using Adobe Premiere Pro CS6.
Screencast - Getting to Know the Pipeline

926 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