简体   繁体   English

在LINQPad中,F#中C#的.Dump()方法的等价物是什么?

[英]In LINQPad , what is the equivalent of C#'s .Dump() method in F#?

In LINQPad , what is the equivalent of C#'s .Dump() method in F#? 在LINQPad中,F#中C#的.Dump()方法的等价物是什么?

For example, what is the quickest way to dump the below C# in F# syntax? 例如,在F#语法中转储下面的C#的最快方法是什么?

var nums = new List<int> { 1, 2, 3, 4, 5 };
nums.Dump();

And

let nums = [1; 2; 3; 4; 5]

This works for me: 这对我有用:

let nums = [1; 2; 3; 4; 5]
nums.Dump()

You can also use Dump as a function: 您还可以使用Dump功能:

let nums = [1; 2; 3; 4; 5]
Dump nums
nums |> Dump
(* ... *)

Aside from the already given .Dump() method, you should know it is also automatically invoked when you write a collection (and other types) to the console: 除了已经给定的.Dump()方法之外,您应该知道在将一个集合(和其他类型)写入控制台时也会自动调用它:

let nums = [1; 2; 3; 4; 5]
Console.WriteLine(nums);

will also give you the dump. 也会给你转储。

This one can be used in the middle of a piped workflow too, because it return his input. 这个也可以在管道工作流程的中间使用,因为它返回他的输入。

let DumpHelper (caption:string) a =
 a.Dump(caption)
 a

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM