private string GetIndexByGenreInCollection(XCollection<Genre> genres, Genre genre) { string res = string.Empty; if (genres != null) { if (genres.Contains(genre)) { int index = genres.IndexOf(genre); return index.ToString(CultureInfo.InvariantCulture); } else { for (int i = 0; i < genres.Count; i++) { string idx = GetIndexByGenreInCollection(genres[i].Children, genre); if (!string.IsNullOrEmpty(idx)) { res = i.ToString(CultureInfo.InvariantCulture) + ":" + idx; break; } } } } return res; }