user3685285
user3685285

Reputation: 6586

F# - What is the best way to convert a char[] to a string?

Is there an easy way to convert a char[] to string in F# without explicitly looping over the array? I tried:

let char_arr = [|'a','b','c'|]
let str = new String(char_arr)

but that doesn't work. Suggestions?

Upvotes: 0

Views: 3265

Answers (1)

FoggyFinder
FoggyFinder

Reputation: 2220

The array elements are separated by ';'

let char_arr = [|'a';'b';'c'|]
let str = new string(char_arr)
str |> printfn "%A"

Link: http://ideone.com/scp7qb

Upvotes: 5

Related Questions