编码新行 [英] code new line
本文介绍了编码新行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
您好,我想通过代码为程序添加新行的所有可能的帮助
TextReader tr = new StreamReader("c:\\date.txt"); // read a line of text String s1 = tr.ReadLine(); // close the stream //String s1 = "One Two Three Four"; char[] seps = {'' ''}; String[] values = s1.Split(seps); TextWriter tw1 = new StreamWriter("d:\\bdate1.txt"); // write a line of text to the file // close the stream for (int i = 0; i < values.Length; i++) { tw1.WriteLine(values[i]); } tr.Close(); tw1.Close();
解决方案
使用Environment.NewLine
tw1.WriteLine(Environment.NewLine);
使用\ r \ n常量
tw1.WriteLine(" ); pre>
您完全不能使用任何参数:
tw1.WriteLine();
Hello to all possible help I want to code to add a new line of the program
TextReader tr = new StreamReader("c:\\date.txt"); // read a line of text String s1 = tr.ReadLine(); // close the stream //String s1 = "One Two Three Four"; char[] seps = {'' ''}; String[] values = s1.Split(seps); TextWriter tw1 = new StreamWriter("d:\\bdate1.txt"); // write a line of text to the file // close the stream for (int i = 0; i < values.Length; i++) { tw1.WriteLine(values[i]); } tr.Close(); tw1.Close();
解决方案
Using Environment.NewLine
tw1.WriteLine(Environment.NewLine);
Using \r\n constant
tw1.WriteLine("\r\n");
You may not use any arguments at all:
tw1.WriteLine();
这篇关于编码新行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文