ToString() - doesnt use my override in debuger window

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • colin

    ToString() - doesnt use my override in debuger window

    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 wrapedElementTy pe = new WrapedType(type );
    string s = wrapedElementTy pe.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 =^.^=



  • Marc Gravell

    #2
    Re: ToString() - doesnt use my override in debuger window

    What is your class inheriting from?

    In particular, is it possible that the base-class has a
    [DebuggerDisplay ("...")] specified, which can be used to tweak the
    appearance of items in the debugger?

    See:

    Comment

    • colin

      #3
      Re: ToString() - doesnt use my override in debuger window

      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

      "Marc Gravell" <marc.gravell@g mail.comwrote in message
      news:OMFzkiZGJH A.3664@TK2MSFTN GP05.phx.gbl...
      What is your class inheriting from?
      >
      In particular, is it possible that the base-class has a
      [DebuggerDisplay ("...")] specified, which can be used to tweak the
      appearance of items in the debugger?
      >
      See:
      http://msdn.microsoft.com/en-us/libr...attribute.aspx

      Comment

      • colin

        #4
        Re: ToString() - doesnt use my override in debuger window

        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 =^.^=


        "Marc Gravell" <marc.gravell@g mail.comwrote in message
        news:OMFzkiZGJH A.3664@TK2MSFTN GP05.phx.gbl...
        What is your class inheriting from?
        >
        In particular, is it possible that the base-class has a
        [DebuggerDisplay ("...")] specified, which can be used to tweak the
        appearance of items in the debugger?
        >
        See:
        http://msdn.microsoft.com/en-us/libr...attribute.aspx

        Comment

        Working...