PC Review


Reply
Thread Tools Rate Thread

Creating and Using custom collections

 
 
Arthur.Net
Guest
Posts: n/a
 
      20th Jun 2008
Let's say I have a class that defines teams and players defined
below: How can I also return a collection of players as part of the
Team class?

<script language="c#">
public class Team
{
public int TeamID {get { return _TeamID; } set { _TeamID =
value; }}
public string TeamName {get { return _TeamName; } set
{ _TeamName = value; }}
public string TeamHomeTown {get { return _TeamHomeTown; } set
{ _TeamHomeTown = value; }}
public DataSet GetTeam(int TeamID)
{
//code to return team info from database
}
}
public class Player
{
public int PlayerID {get { return _PlayerID; } set { _PlayerID
= value; }}
public int TeamID {get { return _TeamID; } set { _TeamID =
value; }}
public string PlayerNumber {get { return _PlayerNumber; } set
{ _PlayerNumber = value; }}
public string PlayerName {get { return _PlayerName; } set
{ _PlayerName = value; }}
public DataSet GetPlayer(int PlayerID)
{
//code to return player info from database
}
}
</script>

 
Reply With Quote
 
 
 
 
Alcides
Guest
Posts: n/a
 
      20th Jun 2008
You can use generics:

using System.Collections.Generic;


.....


private List<Player> mPlayers = new List<Player>;

....

 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
A List of Collections and Custom Collections ExcelMonkey Microsoft Excel Programming 1 20th Dec 2007 10:04 PM
Custom collections rufus Microsoft VB .NET 5 17th Oct 2004 04:39 PM
Creating Collections Jeff Windows XP MovieMaker 6 30th Oct 2003 04:20 AM
Re: Creating Collections 'on the fly' Dave Peterson Microsoft Excel Programming 4 6th Sep 2003 07:20 AM
Creating Collections in C# john sutor Microsoft C# .NET 3 7th Jul 2003 10:23 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 05:50 AM.