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

In C++, we can do:

CStudent s;
cin >> s;

(the operator >> overloaded)

How to make similar thing in C# ?

Thanks.
Harry_KewellAsked:
Who is Participating?
 
TheAvengerConnect With a Mentor Commented:
public class Student {
public Student (string initString)
{
  // Do initialization from the initString
}
}
......
string s = Console.ReadLine ();
Student stud = new Student (s);
0
 
TheAvengerCommented:
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
 
Harry_KewellAuthor Commented:
Could you give more detail explanations ? Thanks.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.