Practical lab: build an order summary
Combine parsing, validation, and grouped totals in one workflow.
- Produce a deterministic report from mixed-quality input.
In real services and internal tooling, many jobs transform raw records into grouped summaries. This lab combines split parsing, validation, and dictionary aggregation into one end-to-end script.
1using System;
2
3class Program
4{
5 static void Main()
6 {
7 string row = "north,14";
8 string[] parts = row.Split(',');
9 Console.WriteLine(parts[0]);
10 }
11}north
Treat malformed rows and invalid amounts as expected data quality issues. Reliable scripts make rules explicit and preserve stable output formatting.
Key takeaways
Treat malformed records as expected operational scenarios.
Keep report contracts deterministic.
Combine parsing, validation, and grouping in one coherent flow.
Lesson quiz
5 questions · pass with 4 correct · up to 50 XP
Passing this quiz completes the lesson and keeps your streak going. Questions you miss come back in review sessions later.
Practice: write C#
Write C# 12 in the editor and run it against sample input. .NET 8 compiles and runs the code through Wandbox, a free public service; your source and test input are sent there.
Build a two-region order report
Read integer n then n lines as region,amount. Valid regions are north and south. Ignore unknown regions and invalid amounts. Print exactly north=<total>; south=<total>.
- Valid and invalid lines
- Only south values
C# 12 code is compiled and run with .NET 8 on Wandbox, a free public service. Your source code and test input are sent to that service.
Questions about this lesson
Stuck? Ask. Figured something out? Share it. Explaining is one of the best ways to learn.
Loading posts…