Solved

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

Posted on 2006-10-19
3
177 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
Comment Utility
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
Comment Utility
Could you give more detail explanations ? Thanks.
0
 
LVL 20

Accepted Solution

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

Featured Post

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Bit flags and bit flag manipulation is perhaps one of the most underrated strategies in programming, likely because most programmers developing in high-level languages rely too much on the high-level features, and forget about the low-level ones. Th…
Article by: Ivo
Anonymous Types in C# by Ivo Stoykov Anonymous Types are useful when  we do not need to follow usual work-flow -- creating object of some type, assign some read-only values and then doing something with them. Instead we can encapsulate this read…
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

744 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

11 Experts available now in Live!

Get 1:1 Help Now