No, the pipe operator can only be used with F # functions, it cannot be used with class constructors, member methods, or static methods. The reason is that the overload supported by these types of methods will complicate F # type inference. However, if you really want to use the pipeline, you can map each element of the char array to a string and then pass this sequence to Seq.concat "" :
s.ToCharArray() |> Array.rev |> Seq.map(string) |> String.concat ""
Or you can wrap the string constructor call with the F # method:
let stringCArrCtor (carr: char[]) = new string(carr) s.ToCharArray() |> Array.rev |> stringCArrCtor
And to answer your last question,
s.ToCharArray() |> Array.rev |> string
cannot be used as it is equivalent
(s.ToCharArray() |> Array.rev).ToString()
and the Array ToString () method is not overridden, so it just returns the name of the reflected type by default.
Stephen swensen
source share