Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I'm not sure what you are expecting, <code>last</code> is always initialized to "", so the += is irrelevant.</p> <p>Seems like the class called Teams is really a game?</p> <p>And I don't think setting HomeTeam, AwayTeam, HomeScore, AwayScore over and over again (and then saving this internally somehow) is a good way to keep track of multiple games.</p> <p>Why don't you look at using a collection of games?</p> <p>Try something like this:</p> <p>In a GamesLib library:</p> <pre><code>using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.ComponentModel; namespace GamesLib { public class Game { public string HomeTeam { get; private set; } public string AwayTeam { get; private set; } public string HomeScore { get; private set; } public string AwayScore { get; private set; } public string Combined { get { return " " + HomeTeam + " " + HomeScore + " - " + AwayScore + " " + AwayTeam; } } public Game(string HomeTeam, string AwayTeam, string HomeScore, string AwayScore) { this.HomeTeam = HomeTeam; this.HomeScore = HomeScore; this.AwayTeam = AwayTeam; this.AwayScore = AwayScore; } } public class Games : List&lt;Game&gt;, INotifyPropertyChanged { public string CombinedTeams { get { var str = ""; foreach (Game g in this) { str += g.Combined; } return str; } } public new void Add(Game g) { base.Add(g); if ( PropertyChanged != null ) { PropertyChanged(this, new PropertyChangedEventArgs("CombinedTeams")); } } public event PropertyChangedEventHandler PropertyChanged; } } </code></pre> <p>In a console program:</p> <pre><code>using System; using System.Collections.Generic; using System.Linq; using System.Text; using GamesLib; namespace TestHarness { class Program { static void Main(string[] args) { var gs = new GamesLib.Games(); gs.PropertyChanged += new System.ComponentModel.PropertyChangedEventHandler(gs_PropertyChanged); var g = new Game("hometeam", "awayteam", "1", "0"); gs.Add(g); g = new Game("lions", "bears", "1", "0"); gs.Add(g); Console.WriteLine("Final result:" + gs.CombinedTeams); } static void gs_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e) { var gs = sender as Games; Console.WriteLine("Changed: " + gs.CombinedTeams); } } } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload