Generate txt with standard format

Asked

Viewed 54 times

-1

all right?

I need to generate a txt file with a default format as below:

D00000002       200014002154129   $9997 7720 0000 0012 *           12/19        *CLARICE LISPECTOR       *0014-00  215412-9       *     %B9997772000000012^CLARICE LISPECTOR

There will be several lines and they will all have to have the same size and space between the data. What is the best way to generate these spaces (need to be space itself, as a blank character) and ensure that the file is ok?

Thank you.

  • define what exactly you mean by the same size and same space

  • Perhaps it is better to put in your question the size and format of each of the elements.

1 answer

0


You can use the methods String.PadLeft or String.PadRight

string str = "Lorem ipsum";
Console.WriteLine(str.PadLeft(15));  // "    Lorem ipsum"
Console.WriteLine(str.PadRight(5));  // "Lorem ipsum   "
  • Hello Danilo, I will test here. Thank you! ;)

Browser other questions tagged

You are not signed in. Login or sign up in order to post.