Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Tostring() display problems

Status
Not open for further replies.

razor24

Programmer
Feb 2, 2003
3
US
I have an object whos Tostring() method returns 4 values that have a small graphic box after each value when displayed. I'm assuming this is the newline special character but I'm trying to remove/replace them and display the string as one sentence. How can I replace the graphic box or remove it? I can't find the special sequence for newline or I'm totally off on what is make those boxes............thanks
 
maybe try and use the stringbuilder function to append your strings together, without the newlines in them? Not sure if this will help, but it should. The weevil of doooooooooom
-The eagle may soar, but the weasel never gets sucked up by a jet engine (Anonymous)
 
Well the Tostring() method returns a single string..It looks like this:
value1[small graphic of a box] value2[small graphic of a box]value3 [small graphic of a box] etc..

It's like displaying the ascii sybol for a newline or something

thanks for the response....
Im still racking the brain on this..

.Net rules!
 
Well its confirmed now, the Replace method of the string class wont replace escape sequences. The debugger told me it was char 10 and the below code proves it...

VideoFormat = VideoMode.ToString();//string with newlines
//the lines below dont work
//VideoFormat.Replace((char)10,' ');
//VideoFormat.Replace('\x10',' ');
//VideoFormat.Replace('\xA',' ');//hex

foreach(char searchchar in VideoFormat)
if(searchchar != 10 )
RealFormat = RealFormat + searchchar;

I had to do this loop code to work around Replace not working...
what a pain in the butt lol........................
 
What class are you calling ToString() on?

ToString is usually inherited from the Object (parent of all objects) object. You can override it if the default implementation isn't doing what you want.

Chip H.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top