打印数组的内容(代码是一行,用于visual studio的立即窗口)

Med*_*Man 21 .net c# visual-studio

你能编写一个方便的代码行来打印数组的内容吗?

我将在Visual Studio 2008的立即窗口中使用它,所以它必须在该窗口中工作.我可能已经遗漏了一些要求,但这正是我想要做的.

BFr*_*ree 31

myArray.ToList().ForEach(Console.WriteLine);
Run Code Online (Sandbox Code Playgroud)

Honestly though, I don't think that'll work in the immediate window. It is a nice trick to print it all in one line, but I think for the immediate window, all you need is this:

? myArray
Run Code Online (Sandbox Code Playgroud)

  • 不能使用lambdas,也不能假设Linq被引用. (4认同)

Ben*_*esh 12

我用:

BitConverter.ToString(bytes); //output: 4A-0B-11-13  etc.
Run Code Online (Sandbox Code Playgroud)

可怜的BitConverter,总是被遗忘.


Pau*_*sey 10

a数组在哪里

?a
Run Code Online (Sandbox Code Playgroud)

  • 只打印前 100 个值 (3认同)

Den*_*ore 8

String.Join("; ", myArray);
Run Code Online (Sandbox Code Playgroud)