protected void AddIfNotEmpty(string key, string value, ErrorData data) { if (!string.IsNullOrEmpty(value)) { //make sure we dont get duplicate keys if (data.ContainsKey(key)) { int index = 1; while (data.ContainsKey(key)) { key = string.Format("{0}-{1}", key, index); index++; } } data.Add(key, value); } }