954,514 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

button returns void, a return keyword must not be followed by an object expression

hi how is it possible to return an array from this:

private void btnResult_Click(object sender, EventArgs e)
{
ArrayList arlist = new ArrayList();

arlist.Add(examResults);

return arlist;
}

Many Thanks

tookerello22
Newbie Poster
7 posts since May 2010
Reputation Points: 10
Solved Threads: 0
 

You can't; an event handler cannot return a value. An event can potentially invoke many methods in different objects, if the event handlers allowed return values, each could potentially return a different value so your event would have multiple return values.

Where are you trying to "return" the arraylist to? What were you hoping to achieve, as i think you may have misunderstood how the return is being handled.

Ryshad
Nearly a Posting Virtuoso
1,307 posts since Aug 2009
Reputation Points: 512
Solved Threads: 246
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You
View similar articles that have also been tagged: