✅ Check if value is within range, throw exception if not - C#