且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

编码新行

更新时间:2023-12-05 14:34:46

使用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();