Calling methods on Objects
Posted
by
Mashael
on Programmers
See other posts from Programmers
or by Mashael
Published on 2012-10-06T17:50:30Z
Indexed on
2012/10/06
21:52 UTC
Read the original article
Hit count: 381
Let's say we have a class called 'Automobile' and we have an instance of that class called 'myCar'. I would like to ask why do we need to put the values that our methods return in a variable for the object? Why just don't we call the method?
For example:
Why should we write:
string message = myCar.SpeedMessage();
Console.WriteLine(message);
instead of:
Console.WriteLine(myCar.SpeedMessage());
© Programmers or respective owner