it's technically possible but not straightforward. Your easiest way would be to create a 2nd formatted variable and watch that instead.
The only way i know of to do this in the watch window is you can actually "watch" an expression by typing it in the watch window as an edit to the variable. The expression would append a formatted toString. This doesn't seem to work with arrays though.
Say however you had a variable "total". your watch would say total and you would double click on it and edit it to say total.ToString("C");
I hope this helps.
I would suggest you to create a new array(stringNumbers), which is having the thousand separator and use it in the watch window for your debugging purpose. After you are done with debugging, you can remove this array.
int[] numbers = { 100000, 300000 };
string[] stringNumbers = numbers.Select(n => n.ToString("N")).ToArray();
You can watch stringNumbers here in the watch window.
As noted in the other answers, it's not directly possible. So until the feature request lands in Visual Studio, you need to manually do it. So to sum up, you can:
DebuggerDisplayAttribute
to change the way members of an object are shown (see this blog entry ) Watch
window (so your first need to add your data in the watch window, and it won't work when you hover over your data). Eg // For a long variable
myLong.ToString("N0")
// For a long array variable (that might slow VSNet down if you have tons of rows)
myLongArray.Select(l => l.ToString("N0"))
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.