private static string GetFirstRole() { IEnumerable<string> roles = GetAvailableRoles(); foreach (string role in roles) { return role; } // no roles found throw new InvalidOperationException("No roles found"); }