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
Johnny Nguyen
NA
6
8.3k
the role of void and return keyword
Apr 18 2011 10:41 PM
Hi Guys!
When try to answer the questions to prepare for text, I got the question like this: Consider the C# method below. What happens if the keyword
return
is removed?
public void FireCannonBall()
{
foreach ( GameObject ball on cannonBalls)
{
if (!ball.alive)
{
ball.alive= true;
ball.position= cannon.position-ball.center;
ball.velocity= new Vector2((float)Math.Cos(cannon.rotation),(float)Math.sin(cannon.rotation))* 5.0f;
return;
}
}
}
I my opinion,if the keyword return is removed, we will meet the error.This class is void class, so it is cannot return. we remove the keyword return,the compiler will not understand and do not return ball.velocity to float type.
Is that the right answer????
Could you please help me to find the correct answer for the question?
Regards
Jonny
Reply
Answers (
2
)
Raising event in another form
the Array