Returning an array of objects

Please support our C# advertiser: Intel Parallel Studio Home
Thread Solved

Join Date: Nov 2009
Posts: 2
Reputation: yodito is an unknown quantity at this point 
Solved Threads: 0
yodito yodito is offline Offline
Newbie Poster

Returning an array of objects

 
0
  #1
25 Days Ago
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!!
Reply With Quote Quick reply to this message  
Join Date: Jul 2009
Posts: 908
Reputation: DdoubleD is a jewel in the rough DdoubleD is a jewel in the rough DdoubleD is a jewel in the rough DdoubleD is a jewel in the rough 
Solved Threads: 145
DdoubleD DdoubleD is offline Offline
Posting Shark
 
1
  #2
25 Days Ago
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.
Reply With Quote Quick reply to this message  
Join Date: Nov 2009
Posts: 2
Reputation: yodito is an unknown quantity at this point 
Solved Threads: 0
yodito yodito is offline Offline
Newbie Poster
 
0
  #3
25 Days Ago
Thank you DoubleD, I'll keep this in mind.
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC