Solved

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

Posted on 2006-10-19
3
178 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 120 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

We all know that functional code is the leg that any good program stands on when it comes right down to it, however, if your program lacks a good user interface your product may not have the appeal needed to keep your customers happy. This issue can…
Performance in games development is paramount: every microsecond counts to be able to do everything in less than 33ms (aiming at 16ms). C# foreach statement is one of the worst performance killers, and here I explain why.
Along with being a a promotional video for my three-day Annielytics Dashboard Seminor, this Micro Tutorial is an intro to Google Analytics API data.
This is used to tweak the memory usage for your computer, it is used for servers more so than workstations but just be careful editing registry settings as it may cause irreversible results. I hold no responsibility for anything you do to the regist…

862 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

25 Experts available now in Live!

Get 1:1 Help Now