❔ How to rewrite this without second foreach? - C#