The question is simple, but I’m not sure if the answer is. What happens on the second line here?
$var = 1.5 [string] $var
One could think that the variable is cast. But the System.Double and System.String isn’t based on each other so that wouldn’t work in this case.
Or one could think that the ToString method of System.Double is called, but this is not the case. If you’re using a language that uses period as it’s decimal separator you might not have noticed this. I’m norwegian and therefore use the nb-NO culture. With this culture the following:
$var = 1.5 [string] $var $var.ToString()
(This could give you an headache since you’ll get 15 if you run “[int] $var.ToString()”)
So what happens? In which cases will “[someclass] $somevar” work and what is actually happening?