TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
A A
NA
21
11.9k
how can a user define your parameters
Oct 8 2013 8:47 PM
how can i send values that the user input, to my constructor in another class. because im trying to achieve this but i cant seem to get it.
for example
class car
{
public car(string x, int y)
{
console.write("This is your favorite car: " + x);// here i want to show the values the user input.
console.write("This is your favorite year: " +y);
}
class main
{
string x;
int y;
car brand = new car (x, y)//here i want the values that the user input to be sent to my constructor in the class car.
console.write("whats you favorite car: ");
brand.x = console.readline();//here i want the user to input any car he wants
console.write("what year is your favorite car: ");
brand.y = double.parse(console.readline());//here i want the user to input any year he wants
}
Reply
Answers (
1
)
Readonly
How to control Database connection in C# Application