class Test
{
    static void Main()
    {
        Console.Write("abcd\b");
        Console.WriteLine();            //@1        Console.WriteLine("abcd\b");    //@2        Console.Write("abcd\b\n");      //@3
        
        Console.Write("abcd\b");        //@4                 }\b 退格 正常情况下应该回退一个位 如 @4但@1 @2 @3 处  其实这三处一个意思  /b不再起作用程序输出:
abcd
abcd
abcd
abc如何解呢?????

解决方案 »

  1.   

    因为 Console.WriteLine()//输出就会有换行 改为Console.Write();//实验下
      

  2.   

    不是 \b 不起作用class Test
    {
        static void Main()
        {
            Console.Write("abcd\b123");
            Console.WriteLine();            //@1        Console.WriteLine("abcd\b123");    //@2        Console.Write("abcd\b123\n");      //@3
            
            Console.Write("abcd\b123");        //@4                 }
    你这样 实验下看123 跟 abcd 是不是在一行且有距离
      

  3.   

    楼上的兄弟,楼主的意思是\b紧接着是\n的话,\b会失效
      

  4.   

    退格\b,并没有把字符吃掉,而只是把当前位置向后移动一格,比如下面两行黑体代码效果是等价的:Console.Write("abcd");
    Console.Write("\b\b");
    Console.CursorLeft -= 2;而回车,则是把光标移动到下一行,同时移动到行首(*有些旧的打字机需要另一个命令\r,才能移动到行首)。
    它同样也没有负责擦除。因此,Console.Write("abcd\b\n")就相当于输出abcd,光标左移一格,光标另起一行,所以看到的输出还是abcd
    而Console.Write("abcd\bX")由于X输出到d所在的缓冲区,并覆盖掉d,我们将看到abcX的输出。下面例子演示了改变光标位置,还算有趣:using System;
    class Program
    {
        static void Main()
        {
            System.Threading.ThreadPool.QueueUserWorkItem(delegate
            {
                string text = "The quick brown fox jumps over the lazy dog";
                while (true)
                {
                    Console.ForegroundColor = ConsoleColor.White;
                    Console.Write(System.Environment.NewLine + text);
                    Console.ForegroundColor = ConsoleColor.DarkYellow;
                    for (int i = text.Length - 1; i >= 0; i--)
                    {
                        Console.CursorLeft = i;
                        Console.Write(text[i]);
                        System.Threading.Thread.Sleep(100);
                    }
                }
            });
            Console.Read();
        }
    }
      

  5.   

    1,2处的console.writeline输出的同时会自动换行和3处的\n一样.所以当你输出的时候会光标自动指到下一行去了.
    你在后面再加句console.readline();
    结果是
    abcd 
    abcd 
    abcd 
    abcd 
    是光标退格,不是删除字符
      

  6.   

    Console.Write("abcd\b");        //@4     
    前辈你说的我懂 我是想知道这个输出 abc 怎么解 并没有字符覆盖d呀
      

  7.   

    Console.Write("abcd\b");        //@4    
    前辈 你说的我懂 我是想知道 这个输出 abc 怎么解 并没有字符覆盖d呀
      

  8.   

    UP!\b只是移动字符而不是删除!
      

  9.   

    访问我的博客 程序员日记  http://www.ideaext.com