469,297 Members | 2,144 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,297 developers. It's quick & easy.

Padright

""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
Aug 2 '07 #1
3 4233
""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?

Aug 2 '07 #2
just found it....yep there was a embedded \r
in each string

Thanks
MJ
just love reading binary files
lol

"Mark Peters" <mp*******@gmail.comwrote in message
news:11**********************@j4g2000prf.googlegro ups.com...
>""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?

Aug 2 '07 #3
MikeJ <ve***********@sbcglobal.netwrote:
""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#.)

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too
Aug 2 '07 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by john sutor | last post: by
1 post views Thread by jimmy chao via .NET 247 | last post: by
3 posts views Thread by John A Grandy | last post: by
2 posts views Thread by Bill Nguyen | last post: by
20 posts views Thread by djc | last post: by
2 posts views Thread by lmnorms1 | last post: by
reply views Thread by Paul Ilacqua | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by suresh191 | last post: by
reply views Thread by harlem98 | last post: by
1 post views Thread by Geralt96 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.