ToString() - doesnt use my override in debuger window

C

colin

Hi,
I have overriden ToString() in a class derived from TypeDelegator
public class WrapedType : TypeDelegator
{
........
public string _displayName;
public override string ToString()
{
return "_" + _displayName + "_";
}
}

it uses my override when I call it directly ie-

WrapedType wrapedElementType = new WrapedType(type);
string s = wrapedElementType.ToString();

but in the IDE debugger window its clearly not using my overriden function.

is there something native causing this behavour or have I done something
silly?

the TypeDelegator is quite complicated and various interfaces are inheritted
wich themselves have ToString().

im using vs2005 express, and it displays my other overiden ToString
functions
from other classes ok in the debugger.

thanks
Colin =^.^=
 
C

colin

thanks, its inheriting from TypeDelegator

ive looked in the metadata for that class and all the classes
and interfaces it inherits from, I didnt see that attribute,
however there are lots of classes and interfaces so i might of missed
something.
each one has quite a lot of attributes wich i dont know much about.

however that DebuggerDisplay is usefull feature in itself that I didnt know
about :)

Colin
 
C

colin

actually that also provided a solution, despite not finding any such
attributes from stoping it working.
I just added the folowing line to the class and it displayed as I inteneded
in the debugger.
[DebuggerDisplay("{ToString()}")]

I'l look into this a bit more and see if I can get some of my other classes
to display a bit more clearly in the debugger, like lists and such.

many thanks again
Colin =^.^=
 

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

Top