473,386 Members | 1,803 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

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

Sep 18 '08 #1
3 1385
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
Sep 18 '08 #2
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" <ma**********@gmail.comwrote in message
news:OM**************@TK2MSFTNGP05.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

Sep 18 '08 #3
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" <ma**********@gmail.comwrote in message
news:OM**************@TK2MSFTNGP05.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

Sep 19 '08 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Suresh | last post by:
Hi, I need to add a custom ToString method on an Enum Property. The default ToString method expands the whole name. But, I want only an short associated code with the long name of the enum type....
10
by: Ken Allen | last post by:
The ToString() function, when applied to a variable that is an enumeration type, results in a string that is the name of the enumerated value that was defined in the source code. This is cool, but...
7
by: AWHK | last post by:
How can I force anyone who subclasses my class to override the ToString() method? Andreas :-)
10
by: | last post by:
I have a property where I want to associate tostring with it. So that this would be valid: ----- Dim x as string x = myobject.myproperty.tostring ----- I know I have to overide...
12
by: Ron M. Newman | last post by:
hi, without going case-by-case, how do I know a "ToString" method returns useful information, like for Sytem.Int32, or useless information like for System.Drawing.Bitmap (returning the name of...
8
by: kirkox | last post by:
Hi guys, this is my first post here and I am a newbie, of course. My question is simple...I'd like to override toString() function such that it can works on Object. I have something like that...
31
by: Zytan | last post by:
Everything (er, every class) in C# has ToString() which is conveniently automatically invoked when using it in Debug.WriteLine() or in a string concatenation, etc. I made a struct, and I want to...
2
by: Madmartigan | last post by:
Hi I have the following class to write, with respective methods and such(see below). The script I have written so far is also attached. I am battling with two parts of this question. I'd like to...
2
by: Berryl Hesh | last post by:
I'm interested in how experienced.Net developers might handle routine display tasks as a general strategy. Let's say you have a use in your domain for value objects that encapsulate a person's...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.