List <char> CreateTable(string key) { key = key.ToUpper(); List <char> tempList = new List <char>(); List <char> alphbtList = getAlphbt(); tempList = key.Distinct().ToList(); // remove duplicates char from key for (int i = 0; i < tempList.Count; i++) //compare key char and alphbet char and remove duplicates char { for (int j = 0; j < alphbtList.Count; j++) { if (tempList[i] == alphbtList[j]) { alphbtList.Remove(alphbtList[j]); } } } foreach (var item in alphbtList) { tempList.Add(item); } return(tempList); }