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

Harry_Kewell
Harry_Kewell used Ask the Experts™
on
In C++, we can do:

CStudent s;
cin >> s;

(the operator >> overloaded)

How to make similar thing in C# ?

Thanks.
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
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

Author

Commented:
Could you give more detail explanations ? Thanks.
public class Student {
public Student (string initString)
{
  // Do initialization from the initString
}
}
......
string s = Console.ReadLine ();
Student stud = new Student (s);

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial