Padright

  • Thread starter Thread starter MikeJ
  • Start date Start date
M

MikeJ

""NAME","SYSTEM_ID","TAX_ID","LICENSE"";
the Above is one row read in from a text file

its 38 bytes in width i want to pad this to 77
in my code padright is not working correctly unless i string.trimend() the
above row
example

string sRow

sRow = ""NAME","SYSTEM_ID","TAX_ID","LICENSE"";

sRow=sRow.PadRight(77);
Console.Writeline(cRow) ; // ouput is "
ENSE"

//if i trimend this it works
sRow=sRow.TrimEnd();
sRow=sRow.Padright(77);

Console.WriteLine(sRow);

Any thoughts
MJ
 
""NAME","SYSTEM_ID","TAX_ID","LICENSE"";
the Above is one row read in from a text file

its 38 bytes in width i want to pad this to 77
in my code padright is not working correctly unless i string.trimend() the
above row
example

I was able to reproduce the problem in your code with the following
line:
sRow = "\"NAME\",\"SYSTEM_ID\",\"TAX_ID\",\"LICENSE\" \r";

Perhaps you are getting a Carriage Return (\r) and spaces at the end
of your line.

How are you reading in the line from the file?
 
MikeJ said:
""NAME","SYSTEM_ID","TAX_ID","LICENSE"";
the Above is one row read in from a text file

its 38 bytes in width i want to pad this to 77
in my code padright is not working correctly unless i string.trimend() the
above row
example

string sRow

sRow = ""NAME","SYSTEM_ID","TAX_ID","LICENSE"";

sRow=sRow.PadRight(77);
Console.Writeline(cRow) ; // ouput is "
ENSE"

//if i trimend this it works
sRow=sRow.TrimEnd();
sRow=sRow.Padright(77);

Console.WriteLine(sRow);

Any thoughts

Could you post a short but complete program which demonstrates the
problem?

See http://www.pobox.com/~skeet/csharp/complete.html for details of
what I mean by that.

(In particular, the assignment to sRow doesn't compile at the moment -
it isn't valid C#.)
 
just found it....yep there was a embedded \r
in each string

Thanks
MJ
just love reading binary files
lol
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top