Click here to Skip to main content
16,005,069 members
Home / Discussions / C#
   

C#

 
AnswerRe: number of time a window has been opened Pin
Christian Graus9-Nov-09 18:48
protectorChristian Graus9-Nov-09 18:48 
AnswerRe: number of time a window has been opened Pin
dan!sh 9-Nov-09 18:54
professional dan!sh 9-Nov-09 18:54 
QuestionJanus Grid Pin
AndieDu9-Nov-09 18:25
AndieDu9-Nov-09 18:25 
AnswerRe: Janus Grid Pin
AndieDu10-Nov-09 17:05
AndieDu10-Nov-09 17:05 
QuestionError:unable to cast object of type Pin
mjawadkhatri9-Nov-09 18:20
mjawadkhatri9-Nov-09 18:20 
AnswerRe: Error:unable to cast object of type Pin
N a v a n e e t h9-Nov-09 18:27
N a v a n e e t h9-Nov-09 18:27 
GeneralRe: Error:unable to cast object of type Pin
mjawadkhatri9-Nov-09 18:32
mjawadkhatri9-Nov-09 18:32 
QuestionCan't get depth chart to display Pin
rooster21549-Nov-09 18:09
rooster21549-Nov-09 18:09 
I'm having trouble implementing a depth chart for my football simulator program. The way my program is structured, I have a Player class, a Team class, and a League class--the core classes. The depthchart would group players by their position and, by each position, sort by OVR (integer) in descending order (but only if their injury status is "false"--governed by a CanPlay method in my Player class; otherwise, they are not eligible for the depthchart). Position is a PlayerPosition type and PlayerPosition is enumerated as such:
[code]
public enum PlayerPosition { QB, HB, WR, TE, LT, LG, C, RG, RT, DE, DT, OLB, MLB, CB, FS, SS }

[/code]
This is in my Team class:
[code]
public List<Player> depthChart { get; set; }
public List<Player>[] DepthChart
{
    get
    {
        var result = new List<Player>[Enum.GetValues(typeof(PlayerPosition)).Length];
        foreach (PlayerPosition pos in Enum.GetValues(typeof(PlayerPosition)))
        {
            result[(int)pos] = this.Players.Where(pl => pl.position == pos && pl.CanPlay).OrderByDescending(pl => pl.OVR).ToList();
        }
        return result;
    }

[/code]
These are in my Main() method: two attempts to obtain information from the depth chart.

Method 1:
[code]
Team t = league.Teams[0];
var depthChart = t.DepthChart;
Console.WriteLine(depthChart);

[/code]

Method 2: prints out the entire depth chart, not just the starter.
[code]
foreach (PlayerPosition pos in Enum.GetValues(typeof(PlayerPosition)))
{
    Console.Write(pos.ToString() + ':');
    depthChart[(int)pos].ForEach(p => Console.Write(' ' + p.lastName));
    Console.WriteLine();
}

[/code]

For method 1, I get on the console readout: System.Collections.Generic.List`1[FranchiseSim.Player][]
For method 2, I get on the console readout only the proper position strings (like QB, RB, etc.) and the colon (Smile | :) but nothing from the depth chart.
QuestionDataGridViewComboBoxColumn not showing values Pin
sachinkalse9-Nov-09 17:42
sachinkalse9-Nov-09 17:42 
QuestionHow to select rectangles and return value from the selected rectangles? Pin
Zar Ni9-Nov-09 17:19
Zar Ni9-Nov-09 17:19 
AnswerRe: How to select rectangles and return value from the selected rectangles? Pin
Christian Graus9-Nov-09 17:23
protectorChristian Graus9-Nov-09 17:23 
Questiontreeview question? Pin
miss YY9-Nov-09 15:33
miss YY9-Nov-09 15:33 
AnswerRe: treeview question? Pin
PIEBALDconsult9-Nov-09 15:35
mvePIEBALDconsult9-Nov-09 15:35 
QuestionHow to design? [modified] Pin
konglx sir9-Nov-09 14:47
konglx sir9-Nov-09 14:47 
AnswerRe: How to design? Pin
Christian Graus9-Nov-09 15:23
protectorChristian Graus9-Nov-09 15:23 
AnswerRe: How to design? Pin
PIEBALDconsult9-Nov-09 15:37
mvePIEBALDconsult9-Nov-09 15:37 
QuestionHow to call List[int] in other class [modified] Pin
laurisp9-Nov-09 13:57
laurisp9-Nov-09 13:57 
AnswerRe: How to call List[int] in other class Pin
Julianne_juju9-Nov-09 19:19
Julianne_juju9-Nov-09 19:19 
GeneralRe: How to call List[int] in other class Pin
laurisp9-Nov-09 21:29
laurisp9-Nov-09 21:29 
Questionnullrefererence exception Pin
hobbsjas9-Nov-09 13:31
hobbsjas9-Nov-09 13:31 
AnswerRe: nullrefererence exception Pin
Luc Pattyn9-Nov-09 14:33
sitebuilderLuc Pattyn9-Nov-09 14:33 
GeneralRe: nullrefererence exception Pin
hobbsjas9-Nov-09 15:26
hobbsjas9-Nov-09 15:26 
GeneralRe: nullrefererence exception Pin
Luc Pattyn9-Nov-09 15:31
sitebuilderLuc Pattyn9-Nov-09 15:31 
GeneralRe: nullrefererence exception Pin
hobbsjas9-Nov-09 15:53
hobbsjas9-Nov-09 15:53 
GeneralRe: nullrefererence exception Pin
N a v a n e e t h9-Nov-09 16:02
N a v a n e e t h9-Nov-09 16:02 

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.