C # return line and carriage return

I want to share how in C # when writing to the lines in a text file to use the «line feed» (0x0D), «carriage return» (0x0A), a tab character (0x09).
Newlines and carriage returns can be supplied by adding at the end of the line — "\ r \ n".
You can also do this using the property NewLine.
Example:

// create FileStream 
  FileStream fs = new FileStream ("" + filename + "", FileMode.OpenOrCreate, FileAccess.Write); 
StreamWriter sw = new StreamWriter (fs); 
// write a string to a file and insert symbols
  sw.Write (summa_peni + "\ r \ n"); 
// or using NewLine 
  sw.NewLine (); 


The tab character (0x09) can be inserted using "\ t" or "\ x09".
Example:

// using \ t 
sw.Write (dat + "\ t"); 
sw.Write (id_payment + "\ r \ n"); 
 
// using \ x09 
sw.Write (dat + "\ x09"); 
sw.Write (id_payment + "\ r \ n"); 


Any questions? Write.

0 comments

Only registered users can comment.