OH2 convert item state ( String to Number )

Hi,

I try to convert an item string state to number but my code is not working see below:

rule "Code Eingabe"
when
Item Key_Pad received command
then
if( (Key_Pad.state as Number) < 10 )
{
code = ""
code = code + Key_Pad.state
sendCommand(Alarm_Code, code)
}
end

What do I wrong here?

-> code = code + Key_Pad.state.toString