✅ how can i improve this code ? - C#