Re: Type conversions question
- From: Mattias Sjögren <mattias.dont.want.spam@xxxxxxxx>
- Date: Wed, 27 Jul 2005 17:15:48 +0200
> I understand what you are trying to point. However, what I would like to
>achieve is to make the client unaware of the fact that the collection stores
>the data using a type that is not what the user expected, i.e. in this case,
>IMyObject instead of string.
Well how you store it internally is irrelevant as long asn you can
convert all items to the type expected by the client.
You could first convert strings (and for example store in a string
array) and then return an enumerator to that instead.
> Here, the IEnumerator will return an object of type IMyObject. The CLR
>will attempt to convert this type to a string. This is where I would like to
>apply my conversion. Is this possible?
No, any conversion you do must happen before the item is returned by
the enumerator. You can't detect the type of the enumeration variable
the client uses, and type converters or conversion operators will not
help you here since the enumerator returns a reference of type Object.
Mattias
--
Mattias Sjögren [MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.
.
- Follow-Ups:
- Re: Type conversions question
- From: Madhu Gopinathan
- Re: Type conversions question
- References:
- Type conversions question
- From: Madhu Gopinathan
- Re: Type conversions question
- From: Mattias Sjögren
- Re: Type conversions question
- From: Madhu Gopinathan
- Type conversions question
- Prev by Date: Re: Can this be done?
- Next by Date: how can i capture video from a webcam to a file??
- Previous by thread: Re: Type conversions question
- Next by thread: Re: Type conversions question
- Index(es):
Relevant Pages
|