Re: [MSH] Use cast or ToString()?
- From: Chris Warwick <news@xxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Tue, 08 Nov 2005 09:37:10 +0000
On Tue, 08 Nov 2005 09:17:26 +0000, Chris Warwick
<news@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote:
>While parsing through a log file and extracting dates from a regex
>into $matches.date, I noticed that I could use either of the following
>to end up with the numeric day of the month (1..31) as a string :
>
>$day=[string]([datetime]$matches.date).day
>
>or
>
>$day=([datetime]$matches.date).day.tostring()
>
>Is it "Better" to use the cast or the ToString() method? Any views?
>
>Thanks,
>Chris
Just thinking about this some more, it occurs to me that the cast
probably ends up invoking the ToString() method anyway - is this the
case? If this it what happens then I'd personally prefer the second
syntax since it states explicitly what should be done...
Keen to hear other views though!
Chris
.
- Follow-Ups:
- Re: [MSH] Use cast or ToString()?
- From: Jeff Jones [MSFT]
- Re: [MSH] Use cast or ToString()?
- References:
- [MSH] Use cast or ToString()?
- From: Chris Warwick
- [MSH] Use cast or ToString()?
- Prev by Date: [MSH] Use cast or ToString()?
- Next by Date: RE: Relative Path in Create Shortcut Script
- Previous by thread: [MSH] Use cast or ToString()?
- Next by thread: Re: [MSH] Use cast or ToString()?
- Index(es):
Relevant Pages
|