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
Guest User
Tech Writer
357
121.1k
Why does the return statement have to be t.x; ?
Aug 21 2012 12:06 PM
Hi
Given the following code I came across:-
class
MyImmutableType
{
public
readonly
double
x;
public
MyImmutableType(
double
_x) { x = _x; }
public
MyImmutableType
Square() {
return
new
MyImmutableType
(x*x); }
}
static
double
SomeMethod(
MyImmutableType
t)
{
t = t.Square();
return
t.x;
}
Why does the return statement have to be t.x;
rather than just t, as t holds the return value of Square?
I appreciate that the return type of SomeMethod is double and x is of type double so it could be due to a type conversion\cast error.
Regards
Steven
Reply
Answers (
3
)
Can anyone provide me a sample project of VB.NET 2005?
IComparable