private struct MultiRating
{
public float totalRating;
public int totalVotes;
public MultiRating(float rating){
this.totalRating = rating;
this.totalVotes = 1;
}
public float Rating {
get { return this.totalRating / (float) this.totalVotes; }
set { this.totalRating += value; this.totalVotes += 1; } }
public float TotalRating { get { return this.totalRating; } }
public float TotalVotes { get { return this.totalVotes; } }
}
public List<Song> GenerateNextSongs(int count)
{
Dictionary<Song,MultiRating> songs = new Dictionary<Song,MultiRating>();
foreach(SongRating sr in this.UserRatings)
{
if (songs.ContainsKey(sr.Song))
// PROBLEM HERE:
songs[sr.Song].Rating = sr.Rating;
else
songs.Add(sr.Song, new MultiRating(sr.Rating));
}
// ...
}
// Error:
error CS1612: Cannot modify the return value of `System.Collections.Generic.Dictionary<ClubMix.Song,ClubMix.Room.MultiRating>.this[...]' because it is not a variable