switch to create number of symbols This code shows an icons from the Segoe MDL2 Assets font, depending on the number in a variable. However, I'm sure there is a more elegant way of doing this.

switch (numberOfPeople)
{
    case 0:
        return "";
    case 1:
        return "\xE77B";
    case 2:
        return "\xE77B \xE77B";
    case 3:
        return "\xE77B \xE77B \xE77B";
    case 4:
        return "\xE77B \xE77B \xE77B \xE77B";
    default:
        break;

}
I'm sure there is a more elegant way of doing this.


Indeed. With LINQ. You can generate multiple instances with Repeat and join them with string.Join

var symbol = "\xE77B";
var separator = " ";
var count = 5
var result = string.Join(separator, Enumerable.Repeat(symbol, count));


This will work with count = 0 too and generate an empty string.