944,196 Members | Top Members by Rank

Ad:
  • C# Discussion Thread
  • Marked Solved
  • Views: 703
  • C# RSS
Nov 5th, 2009
0

Returning an array of objects

Expand Post »
Hello, I'm a newbie on C# and I have a question in two parts.
Say I have a class Team that defines name and location. I need to write a method that returns an array of Teams.
My first question is... by best pracitce, should I define this method within my Team class? or should it be out side since its returning an array of teams.... (or it doesn't matter)
My second question is, what's the best way to return an array of objects? ArrayList?

Thanks in advance!!
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
yodito is offline Offline
2 posts
since Nov 2009
Nov 5th, 2009
1
Re: Returning an array of objects
If not required to use Array or ArrayList, I wouldn't use either. Use a typed list instead: List<> .

I would put the method outside of your Team class, but it really depends on where you intend to store your Team list or array.

The best way to return an array or list of objects depends on how you intend to use the returned object.
Reputation Points: 341
Solved Threads: 233
Posting Shark
DdoubleD is offline Offline
984 posts
since Jul 2009
Nov 5th, 2009
0
Re: Returning an array of objects
Thank you DoubleD, I'll keep this in mind.
Reputation Points: 10
Solved Threads: 0
Newbie Poster
yodito is offline Offline
2 posts
since Nov 2009

This thread is solved

Either the thread starter or a moderator has marked this thread as solved. You can most likely trust the responses and answers given. There is most likely no reason for any further responses to be posted here. If you have a related question, please start a new thread in this forum instead.

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in C# Forum Timeline: MySql table data always null values on INSERT
Next Thread in C# Forum Timeline: close button event for form





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC