static void Main(string[] args) { var r = abc(2); Console.Write(r.Key + "=" + r.Value); Console.Read(); } static System.Collections.Generic.KeyValuePair<string,int> abc(int n) { n = n + 1; int k = 25; string str = ""; int r = 0; System.Collections.Generic.KeyValuePair<string, int> result; for (int i = 1; i < n; i++) { if (i == 1) { str = k.ToString(); r = k; } else { r = r + k * i; str = str + "+" + k * i; } //Console.WriteLine(str); } result = new KeyValuePair<string, int>(str, r); return result; }