In C++ I could do this, but I don't see how to do it in C#. Basically I want to use a format specifier in the Watch Window of my Visual Studio 2008 debugger to view only a slice or portion of an array. For example, if I have a 2D array like so:
int[,] myArray = new int[5,15]
I might only want to view the last 15 items in the list, so I would like to be able to put this into my watch window (or something similar):
myArray[5],15
Is there anything like this in Visual Studio?
The format specifiers supported by Visual Studio 2008 debugger is described here. Clearly, the C# debugger does not support the same specifiers as C++.
Building on @Omers answer, you could watch a "processed" version of the array using the following watch expression:
System.Linq.Enumerable.Reverse(System.Linq.Enumerable.Take(System.Linq.Enumerable.Reverse(x), 2)), results
Note: the results
format specifier is useful when watching IEnumerable
results when you're interested in the results only.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With