Int and String F# [closed]

本秂侑毒 提交于 2019-12-30 04:38:04

问题


I have a function in F#, where I take an int value and return the int as a string.

let inttostring (x:int):string = 
    ""+x

I can't get ToString to work. Any help would be appreciated.


回答1:


Empty string "" isn't compatible with x which is of int type. You can use

let int2String x = sprintf "%i" x

or

let int2String (x: int) = string x


来源:https://stackoverflow.com/questions/12202626/int-and-string-f

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!