public int BookNumberFromAbbreviation(string book) { book = Regex.Replace(book, @"\s+", ""); // remove all space if (BookList.ContainsKey(book)) { return(BookList.Keys.ToList().IndexOf(book)); } else { string bookKey = BookList.Where(t => t.Value.Item1.Contains(book)).Select(t => t.Key).SingleOrDefault(); return(BookList.Keys.ToList().IndexOf(bookKey)); } }