Int和String F# [英] Int and String F#
本文介绍了Int和String F#的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在F#中有一个函数,我在其中取一个 int
值并返回 int
作为 string
。
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
我无法让ToString工作。任何帮助将不胜感激。
I can't get ToString to work. Any help would be appreciated.
推荐答案
空字符串 isn'与
x
兼容,它是 int
类型。您可以使用
Empty string ""
isn't compatible with x
which is of int
type. You can use
let int2String x = sprintf "%i" x
或
let int2String (x: int) = string x
这篇关于Int和String F#的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文