Click here to Skip to main content
15,907,149 members
Home / Discussions / C#
   

C#

 
GeneralRe: about database Pin
padmanabhan N29-Oct-09 19:57
padmanabhan N29-Oct-09 19:57 
GeneralRe: about database Pin
Christian Graus29-Oct-09 20:57
protectorChristian Graus29-Oct-09 20:57 
GeneralRe: about database Pin
miss YY1-Nov-09 20:40
miss YY1-Nov-09 20:40 
Questionabout tree view Pin
miss YY29-Oct-09 18:35
miss YY29-Oct-09 18:35 
AnswerRe: about tree view Pin
Christian Graus29-Oct-09 18:45
protectorChristian Graus29-Oct-09 18:45 
GeneralRe: about tree view Pin
vivasaayi29-Oct-09 19:09
vivasaayi29-Oct-09 19:09 
QuestionNeed advice and help with editing arraylists Pin
rooster215429-Oct-09 17:17
rooster215429-Oct-09 17:17 
AnswerRe: Need advice and help with editing arraylists Pin
Luc Pattyn29-Oct-09 17:33
sitebuilderLuc Pattyn29-Oct-09 17:33 
Hi,

first some comments on your current code:
1. you have "Player" as a type although your description said a player was an array.
2. the foreach loop won't compile as teams does not contain players, it contains zero or more teams.
3. the first line "CBCalc(int SPD);" won't compile as you don't specify type when calling a method, and SPD is unknown.

I do not particularly like your data organization; the structure is OK, the types are not:

1. each player should be an object, an instance of class Player, and not an array. Inside class Player, you could store whatever data you want to keep for players (first name, last name, day of birth, ...), each using the proper type.

2. assuming each player belongs to a single team, each team should be a List<Player> which is slightly easier to use than an ArrayList. I would be inclined to have a Team class that inherits from List<Player>

3. and then you could have a List<Team> to hold your teams.

So the fundamental organization remains the same, the collections used are different (no arrays and no ArrayLists).

Now to iterate over all players, the code would be:
C#
foreach (Team team in teams) {
    foreach (Player player in team) {
        ... whatever
    }
}

// where
public class Player {
    string lastName;
    DateTime DOB;
    ...
}

public class Team : List<Player> {
    ... you don't need much code in here, as you can use all the methods inherited from List,
    ... e.g. you can do Team.Add(new Player());
}


Hope this helps. If you're unfamiliar with any of this, try reading a book on C#, then come back with specific questions.

Smile | :)

Luc Pattyn

I only read code that is properly indented, and rendered in a non-proportional font; hint: use PRE tags in forum messages


GeneralRe: Need advice and help with editing arraylists Pin
rooster215431-Oct-09 14:49
rooster215431-Oct-09 14:49 
GeneralRe: Need advice and help with editing arraylists Pin
Luc Pattyn31-Oct-09 15:17
sitebuilderLuc Pattyn31-Oct-09 15:17 
QuestionTake pictures with multiple webcams Pin
toby3129-Oct-09 17:09
toby3129-Oct-09 17:09 
AnswerRe: Take pictures with multiple webcams Pin
Christian Graus29-Oct-09 18:46
protectorChristian Graus29-Oct-09 18:46 
QuestionPressing buttons in a webpage programmatically Pin
Nanostrike29-Oct-09 12:07
Nanostrike29-Oct-09 12:07 
AnswerRe: Pressing buttons in a webpage programmatically Pin
Christian Graus29-Oct-09 12:33
protectorChristian Graus29-Oct-09 12:33 
AnswerRe: Pressing buttons in a webpage programmatically Pin
Naruki30-Oct-09 0:13
Naruki30-Oct-09 0:13 
Questiontext formatting in two language Pin
Milad79429-Oct-09 10:26
professionalMilad79429-Oct-09 10:26 
AnswerRe: text formatting in two language Pin
Abhishek Sur29-Oct-09 10:38
professionalAbhishek Sur29-Oct-09 10:38 
Questionhow to open Image n Video file header in c# Pin
shrikant121329-Oct-09 8:29
shrikant121329-Oct-09 8:29 
AnswerRe: how to open Image n Video file header in c# Pin
Dave Kreskowiak29-Oct-09 10:39
mveDave Kreskowiak29-Oct-09 10:39 
AnswerRe: how to open Image n Video file header in c# Pin
Abhishek Sur29-Oct-09 10:40
professionalAbhishek Sur29-Oct-09 10:40 
GeneralRe: how to open Image n Video file header in c# Pin
Christian Graus29-Oct-09 12:06
protectorChristian Graus29-Oct-09 12:06 
GeneralRe: how to open Image n Video file header in c# Pin
shrikant121329-Oct-09 15:33
shrikant121329-Oct-09 15:33 
GeneralRe: how to open Image n Video file header in c# Pin
Christian Graus29-Oct-09 18:47
protectorChristian Graus29-Oct-09 18:47 
GeneralRe: how to open Image n Video file header in c# Pin
shrikant121330-Oct-09 6:15
shrikant121330-Oct-09 6:15 
QuestionObject.Equals(object one, object two) vs Object.ReferenceEquals(object one, object two) [SOLVED] Pin
CaptainSeeSharp29-Oct-09 8:16
CaptainSeeSharp29-Oct-09 8:16 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.