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)), resultsNote: the
resultsformat specifier is useful when watchingIEnumerableresults when you’re interested in the results only.