Create a text file based on position and length
Create a text file based on position and length
I have a requirement to create a text out put based on position and length of fields. For example
The value of code and filler comes from a class when i create text file it has to match the above requirements
object o1 = "00";
object o2 = "00000";
Console.WriteLine(""" + o1.ToString().PadLeft(8) + """);
Console.WriteLine(""" + o2.ToString().PadRight(8) + """);
Console.ReadLine();
And....? Have you done any kind of work and are you willing to show your efforts here? Or are just asking someone to write the code for you?
– Steve
Jul 2 at 13:35
I just started with a POC now //string txt = "Hello World"; //string txt2 = "Test"; //string txt3 = "Let's go"; //string line = String.Format("{0,-15} {1,-10} {2,10}", txt, txt2, txt3); //Console.WriteLine(line); //Console.ReadLine(); object o1 = "00"; object o2 = "00000"; Console.WriteLine(""" + o1.ToString().PadLeft(8) + """); Console.WriteLine(""" + o2.ToString().PadRight(8) + """); Console.ReadLine();
– user2524109
Jul 2 at 13:40
Please put your code in the question with an edit. It's unreadable as a comment... IT looks like you are on the right track though (from what I can make of it)!
– JNevill
Jul 2 at 13:41
If the output of o1 and o2 must be on the same line then use Console.Write instead of WriteLine
– Steve
Jul 2 at 13:45
By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.
What errors are you getting? What problems are you having? What code do you have thus far?
– PrestonM
Jul 2 at 13:35