ms_learn_csharp/022_array_operations/orders/Program.cs
2024-07-31 22:38:31 -04:00

15 lines
446 B
C#

string order_stream = "B123,C234,A345,C15,B177,G3003,C235,B179";
string[] order_ids = order_stream.Split(',');
Array.Sort(order_ids);
foreach (var order_id in order_ids) {
int id_length = order_id.Length;
if (id_length == 4) {
Console.WriteLine(order_id);
} else {
int remainder = 8 - id_length;
string spaces = new String(' ', remainder);
Console.WriteLine(order_id + spaces + "- Error");
}
}