I will first declare the main question here so you can skip the rest if you like.
How do I make result list sorted alphabetically?
public static List<string> GenerateMonthNames(string prefixText)
{
List<string> items = new List<string>();
items.Add("a");
items.Add("appl");
items.Add("ap");
items.Add("apple");
items.Add("change");
items.Add("world");
items.Add("engaging");
string[] strArray = items.ToArray();
string tempFundstr = string.Empty;
List<string> returnedList= new List<string>();
int strNumber;
int strIndex = 0;
for (strNumber = 0; strNumber < strArray.Length; strNumber++)
{
strIndex = strArray[strNumber].IndexOf(prefixText);
if (strIndex >= 0)
{
tempFoundStr = strArray[strNumber];
retLst.Add(retstr);
}
}
items.Clear();
return returnedList;
}
it was desperate try on Ajax autoComplete just…to get it working, without using Database as source for the autoComplete data
though I have solved main issue, as it wasn’t working at all (;. and now after “fixing” the problem the autoComplete does work. but
it’s kind’a messy solution I have manage to pull in order to iterate through the list or an array the problem here is that I can’t understand how, by using Linq, enumerate or any implementation so i will be able to return the result list sorted alphabetically.
And with your help, i hope to get the code straight (by the book).
Try this: