Skip to content

Instantly share code, notes, and snippets.

@eldewall
Created August 31, 2011 09:03
Show Gist options
  • Select an option

  • Save eldewall/1183127 to your computer and use it in GitHub Desktop.

Select an option

Save eldewall/1183127 to your computer and use it in GitHub Desktop.
public class ObjectCount {
public Dictionary<int, int> Values { get; private set; }
public ObjectCount(Dictionary<int, int> values) {
this.Values = values;
}
public int Total {
get {
return Values.Sum(v => v.Value);
}
}
public int this[int value] {
get {
try {
return Values[value];
}
catch (Exception) {
return 0;
}
}
}
}
Personbilar (@Model.ObjectCount[BBAdmin.Models.ObjectTypes.Car])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment