Re: casting vs. using the "Convert" methods?
From: Alexander Mueller (postmaster_at_127.0.0.1)
Date: 03/18/05
- Next message: Dale Preston: "Re: monitor IIS with C#"
- Previous message: ad: "Can static varible cross session"
- In reply to: Bruce Wood: "Re: casting vs. using the "Convert" methods?"
- Next in thread: Olorin: "Re: casting vs. using the "Convert" methods?"
- Reply: Olorin: "Re: casting vs. using the "Convert" methods?"
- Reply: Bruce Wood: "Re: casting vs. using the "Convert" methods?"
- Messages sorted by: [ date ] [ thread ]
Date: Fri, 18 Mar 2005 03:15:01 +0100
Bruce Wood wrote:
> Not true. The truth is a bit more complex than that. .NET provides
> three methods of getting from point A to point B, as it were.
When I was talking of casting I was of course only talking about casting
in terms of objects and not of primitive types.
>
> Note that the underlying representation _did_ change in this
> conversion: a double is represented completely differently from an int.
Well, because it was a conversion and not a cast.
>
> Note that there is nothing that absolutely requires a method call here.
> The designers could quite easily have created an explicit
> cast operator that converted a string to an int. The requirement that
> you call a method is a stylistic choice rather than a fundamental
> requirement of the language.
As proven by PHP.
> Implicit and explicit casts are method calls too (that's how you make
> your own).
I have to say I am not extremely well familiar with C# internals but I
doubt it calls a method for a simple cast. Casting an instance from
object to string will probably only tell the compiler not to report the
typical incompatible types message - along with additional checks for
possible unsupported casting exceptions.
- Next message: Dale Preston: "Re: monitor IIS with C#"
- Previous message: ad: "Can static varible cross session"
- In reply to: Bruce Wood: "Re: casting vs. using the "Convert" methods?"
- Next in thread: Olorin: "Re: casting vs. using the "Convert" methods?"
- Reply: Olorin: "Re: casting vs. using the "Convert" methods?"
- Reply: Bruce Wood: "Re: casting vs. using the "Convert" methods?"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|