public string[] KeyValuePairs() { IEnumerator e; string[] result; int item; e = ViewState.GetEnumerator(); result = new string[ViewState.Keys.Count]; item = 0; while (e.MoveNext()) { DictionaryEntry d; StateItem si; d = (DictionaryEntry)e.Current; si = (StateItem)d.Value; if (si.Value is String[]) { string[] values; values = (string[])si.Value; result[item] = d.Key.ToString() + "="; if (values.Length > 0) { result[item] += values[0]; for (int i = 1; i < values.Length; i++) { result[item] += ", " + values[i]; } } } else { result[item] = d.Key.ToString() + "=" + si.Value; } item++; } return(result); }