How to create all combination of two letters and write them to a textfile in C#

1 Answer

0 votes
using System;
using System.IO;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            letters_2();
             
        }
        private static void letters_2()
        {
            string s = "abcdefghijklmnopqrstuvwxyz", w;

            StreamWriter sw = File.CreateText(@"d:\2letters-combination.txt");

            for (int i = 0; i < s.Length; i++)
            {
                for (int j = 0; j < s.Length; j++)
                {
                    w = s[i].ToString() + s[j].ToString();
                    sw.WriteLine(w);
                }
            }
            sw.Close();
        }
    }
}


answered Apr 9, 2014 by avibootz

Related questions

1 answer 198 views
1 answer 96 views
2 answers 91 views
1 answer 87 views
1 answer 76 views
1 answer 271 views
...