In unit test I would like to hard code a block of lines as a string.
In C# I would do
var sb = new StringBuilder();
sb.AppendLine("myline1");
sb.AppendLine("myline2");
sb.AppendLine("myline3");
Since I converted to F# I tried to minimize the usage of .Net method by using bprintf instead, but somehow there is no bprintfn support which seems strange to me.
It is tedious to add \r\n at the end of each line manually.
Or is there any better way than StringBuilder?
I think there is no problem with using
StringBuilderin F# as you did.There is a function
fprintfnin Printf module, so you can use it with aStringWriterobject:I like
fprintfandfprintfnsince they are flexible. You can write to console output by supplyingstdoutinstead.