| | |
Returning an array of objects
Please support our C# advertiser: Intel Parallel Studio Home
Thread Solved |
•
•
Join Date: Nov 2009
Posts: 2
Reputation:
Solved Threads: 0
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!!
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!!
•
•
Join Date: Jul 2009
Posts: 908
Reputation:
Solved Threads: 145
1
#2 25 Days Ago
If not required to use Array or ArrayList, I wouldn't use either. Use a typed list instead:
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.
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.
![]() |
Similar Threads
- Help, how would I store an array of objects ? (Java)
- returning array from ajax.responseText? (JavaScript / DHTML / AJAX)
- Dynamic memory for an array of objects (C++)
- returning an array? (C++)
- single array objects (Java)
Other Threads in the C# Forum
- Previous Thread: MySql table data always null values on INSERT
- Next Thread: close button event for form
| Thread Tools | Search this Thread |
.net access ado.net algorithm array backup barchart bitmap box broadcast buttons c# check checkbox client combobox control conversion csharp custom database databasesearch datagrid datagridview datagridviewcheckbox dataset datetime degrees development draganddrop drawing dynamiccreation encryption enum equation event excel file form format formatting forms function gdi+ httpwebrequest image index input install interface java label list listbox mandelbrot math mouse mouseclick mysql namevaluepairs operator path photoshop picturebox pixelinversion post powerpacks programming property radians regex remote remoting resource restore richtextbox server sleep socket sql statistics stream string table text textbox thread time timer update usercontrol validation visualstudio wait webbrowser windows winforms working wpf xml





