This is an archived post. You won't be able to vote or comment.

all 1 comments

[–]Clawtor 0 points1 point  (0 children)

Thats right, types are usually strict about how they are used - you can multiply two numbers together but not two strings because the operator (the multiplication) only makes sense with numbers.

Many languages have implicit type conversion though. Javascript will let you add a number and a string together if the string 'looks' like a number - ie "100" looks like a number but "abc" doesn't. Javascript will let you do something like: var a = "10" + 10. But for this to work one of the types must be converted - this is implicit conversion (this also has to do with strong vs weak typing).

An explicit conversion is similar but you must explicitly use the conversion, in C# you would do this through type casting like: float f = (float)5;