[Webinar] Streamline your web hosting managementRegister Today

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 190
  • Last Modified:

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.
0
Harry_Kewell
Asked:
Harry_Kewell
  • 2
1 Solution
 
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
 
TheAvengerCommented:
public class Student {
public Student (string initString)
{
  // Do initialization from the initString
}
}
......
string s = Console.ReadLine ();
Student stud = new Student (s);
0

Featured Post

[Webinar] Kill tickets & tabs using PowerShell

Are you tired of cycling through the same browser tabs everyday to close the same repetitive tickets? In this webinar JumpCloud will show how you can leverage RESTful APIs to build your own PowerShell modules to kill tickets & tabs using the PowerShell command Invoke-RestMethod.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now