string a = "a";
Console.WriteLine(a.PadRight(10,a[0]));
输出10个 a

解决方案 »

  1.   

    using System;
    using System.IO;
    using System.Text;class Test 
    {
        public static void Main() 
        {
            int n;            //你要写入的次数
            string temp="a";  //你要写入的字符串
            StringBuilder sb = new StringBuilder();        string path = @"c:\temp\MyTest.txt";
            if (!File.Exists(path)) 
            {
                // Create a file to write to.
                using (StreamWriter sw = File.CreateText(path)) 
                {
                    for (int i=1;i<=n;i++)
                    {
                       sb = sb.Append(temp);
                    }
                    sw.WriteLine(sb.ToString());
                }    
            }        // Open the file to read from.
            using (StreamReader sr = File.OpenText(path)) 
            {
                string s = "";
                while ((s = sr.ReadLine()) != null) 
                {
                    Console.WriteLine(s);
                }
            }
        }
    }
      

  2.   

    http://community.csdn.net/Expert/topic/3134/3134358.xml?temp=.5690424帮忙看看!大哥们!急得很!
      

  3.   

    如果是填充字符的化,就用一个函数搞定算了。
    [C#]
    public string PadLeft(
       int totalWidth,
       char paddingChar
    );
    [C#]
    public string PadRight(
       int totalWidth,
       char paddingChar
    );