为什么Console.WriteLine()函数会丢失字符串中的某些字符? [英] Why does Console.WriteLine() function miss some characters within a string?
本文介绍了为什么Console.WriteLine()函数会丢失字符串中的某些字符?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个字符串,声明为:
I have a string, declared as:
string text = "THIS IS LINE ONE "+(Char)(13)+" this is line 2";
但是,当我写 Console.WriteLine(text);
,
输出为:
this is line 2E
为什么会发生这种情况?还是因为我愚蠢而缺少明显的东西?
Why is this behaviour happening? Or is it because I'm being stupid and missing something obvious?
为什么不打印:
THIS IS LINE ONE [CR] //where the CR is a non printed character
this is line 2
编辑
请注意:这不是不是 如何添加回车符问题。
Please note: this is NOT a 'how do I add a carriage return' question.
推荐答案
(char)13
是回车符(返回)(在当前行的左边距)
(char)13
is a carriage return (To the left margin on the current line)
THIS IS LINE ONE \r this is line 2"
被解释为:
打印此行第一行
然后*返回*并打印此行2
重叠是:E
所以您看到:这是第2E行
这篇关于为什么Console.WriteLine()函数会丢失字符串中的某些字符?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文