Answer to Question #63456 in C# for Peter
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)
1
2016-11-19T11:19:12-0500
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!
Learn more about our help with Assignments:
C#
Comments
We reuploaded the answer, please check.
what are these quot parts appearing for?
Leave a comment