/// <summary> /// Takes a string array and converts it into a sentence /// </summary> /// <param name="items"></param> /// <returns></returns> public static string Sentenceify(string[] items, SentenceifyOptions option = SentenceifyOptions.AND) { items = items.Select(x => x.Clean()).Where(x => x != null).ToArray(); if (items.Length == 0) { return(null); } else if (items.Length == 1) { return(string.Concat("‘<span class=\"bold-small\">", items[0], "</span>’")); } else { return(string.Concat("‘<span class=\"bold-small\">", string.Join("</span>’, ‘<span class=\"bold-small\">", items.Take(items.Length - 1)), "</span>’", SPACE, option.ToString().ToLower(), SPACE, "‘<span class=\"bold-small\">", items.Last(), "</span>’")); } }
public static string SentencifyNoFormating(string[] items, SentenceifyOptions option = SentenceifyOptions.AND) { items = items.Select(x => x.Clean()).Where(x => x != null).ToArray(); if (items.Length == 0) { return(null); } else if (items.Length == 1) { return(items[0]); } else if (items.Length == 2) { return(string.Join(string.Concat(SPACE, option.ToString().ToLower(), SPACE), items)); } else { return(string.Concat(string.Join(", ", items.Take(items.Length - 1)), SPACE, option.ToString().ToLower(), SPACE, items.Last())); } }