The idiomatic way to do this in F # is sprintf:
let newString = sprintf "First Name: %s Last Name: %s" "John" "Doe"
In addition, you have access to .net String.Format:
let newString = String.Format("First Name: {0} Last Name: {1}", "John", "Doe")
The advantage of the first is that it is type safe (that is, you cannot pass a string to integer formatting, for example "% d"). As Benjol pointed out in the comments, it is not possible to pass a format string to sprintf, because it is statically typed. See here for more details .
source
share