List Info

Thread: object.ToString() or TypeConverter




object.ToString() or TypeConverter
user name
2006-07-31 05:04:56
I have a collection of items (object) that I need to
retrieve there
corresponding string value at present I'm calling
ToString() but should
I be calling the corresponding type converter? 

 

Rob.


===================================
This list is hosted by DevelopMentorŪ  http://www.develop.com

View archives and manage your subscription(s) at http://discuss.develop.com

object.ToString() or TypeConverter
user name
2006-07-31 08:14:33
> I have a collection of items (object) that I need to
retrieve there
> corresponding string value at present I'm calling
ToString() but should
> I be calling the corresponding type converter?

That depends upon what you mean by 'corresponding' string
value.
Are your objects "strings" - as in logical
inheritance? Do your objects
have a serialised string representation? Are you trying to
get a
user-displayable description of the object to display on the
UI?

In the absence of detailed knowledge of your architecture,
I'd suggest
that maybe your base class should have a
"MyStringValue" abstract
method that returns the string you want - no ambiguity,
then.

John

===================================
This list is hosted by DevelopMentorŪ  http://www.develop.com

View archives and manage your subscription(s) at http://discuss.develop.com

object.ToString() or TypeConverter
user name
2006-07-31 08:42:30
Surely that's the whole point of the ToString method

Regards

Richard Blewett - DevelopMentor

-----Original Message-----
From: Discussion of development on the .NET platform using
any managed
language [mailtoOTNET-CL
RDISCUSS.DEVELOP.COM] On Behalf Of John Brett
Sent: 31 July 2006 09:15
To: DOTNET-CLRDISCUSS.DEVELOP.COM
Subject: Re: [DOTNET-CLR] object.ToString() or TypeConverter

> I have a collection of items (object) that I need to
retrieve there
> corresponding string value at present I'm calling
ToString() but should
> I be calling the corresponding type converter?

That depends upon what you mean by 'corresponding' string
value.
Are your objects "strings" - as in logical
inheritance? Do your objects
have a serialised string representation? Are you trying to
get a
user-displayable description of the object to display on the
UI?

In the absence of detailed knowledge of your architecture,
I'd suggest
that maybe your base class should have a
"MyStringValue" abstract
method that returns the string you want - no ambiguity,
then.

John

===================================
This list is hosted by DevelopMentorR  http://www.develop.com

View archives and manage your subscription(s) at http://discuss.develop.com


===================================
This list is hosted by DevelopMentorŪ  http://www.develop.com

View archives and manage your subscription(s) at http://discuss.develop.com

[1-3]

about | contact  Other archives ( Real Estate discussion Medical topics )