整数和字符串 F# [英] Int and String F#
本文介绍了整数和字符串 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.
推荐答案
Empty string ""
is not compatible with x
which is of 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
这篇关于整数和字符串 F#的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文