62 499
Assignments Done
98,8%
Successfully Done
In June 2018

Answer to Question #63456 in C# for Peter

Question #63456
I have the following toString method which returns 'result' into a textbox

result += "Driver: " + a.getForename() + " " + a.getSurname() + " (" + a.getOccupation() + ")" + "\r\nClaims: " + a.countClaim() + "\r\n";

I want the Claims: (count), to be aligned to the right side of the text box, how can I do this without aligning everything else?

Example:
Driver: (firstname) (surname)(occupation) ...............................Claims: (count)
Expert's answer
you can't do that.
but you can format the string.

int maxLen = 50; // where maxLen is the desired length of the string
string result = new string('.', maxLen);
char[] chr = new char[maxLen];
result.CopyTo(0, chr, 0, result.Length);
result += "Driver: " + a.getForename() + " " + a.getSurname() + " (" + a.getOccupation() + ")" ;
result.CopyTo(0, chr, 0, result.Length);
a.countClaim().ToString().CopyTo(0, chr, chr.Length - a.countClaim().ToString().Length, a.countClaim().ToString().Length);

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

Assignment Expert
19.11.16, 18:19

We reuploaded the answer, please check.

Peter
19.11.16, 12:59

what are these ''' '"' parts appearing for?

Leave a comment

Ask Your question

Submit
Privacy policy Terms and Conditions