using System.Collections.Generic;
using System.Text.RegularExpressions;
using System.Diagnostics;
public static void Main() {
ViewModel viewModel = new ViewModel {
Taipei = new List<Township> {
new Township { Section = "新店區", Price = "10" },
new Township { Section = "新店區", Price = "200" },
new Township { Section = "新店區", Price = "40" },
new Township { Section = "信義區", Price = "101" },
new Township { Section = "信義區", Price = "2001" },
new Township { Section = "信義區", Price = "401" }
int money1 = viewModel.Taipei == null
: viewModel.Taipei.Where(x => x.Section == "新店區").Sum(x => int.Parse(x.Price));
Console.WriteLine(money1);
int money2 = viewModel.Taipei == null
: viewModel.Taipei.Where(x => x.Section == "信義區").Sum(x => int.Parse(x.Price));
Console.WriteLine(money2);
public IEnumerable<Township> Taipei { get; set; }
public string Section { get; set;}
public string Price { get; set;}