2

I'm working with Ticks a lot at the moment and when setting a timespan/similar, I find the shorthand exponent notation 3e6 far more easy to read at a glance than 3000000

VS converts to the long form as soon as it tidies up the line.

Is there any way to turn off the editor feature which reformats this?

As requested, a screenshot:

enter image description here

Jeremy Thompson
  • 61,933
  • 36
  • 195
  • 321
Basic
  • 26,321
  • 24
  • 115
  • 201

1 Answers1

1

The Timespan.Ticks is a Long so I'm not to sure what you mean by 'VS converts to the long as soon as it tidies up' - its always a long.

Hence you'd either need to use a datatype that supports exponent notation like a double or you could use this method: ts.Ticks.ToString("0.###E+0"). I think the latter method with the QuickWatch window would be the best approach.

Edit: After reading your comments, I need to see a screenshot, here's what my IDE displays:

enter image description here

Jeremy Thompson
  • 61,933
  • 36
  • 195
  • 321
  • I'm not talking about the data type at all - just the number format eg 1000000 = 1e6. I'd prefer to see 1e6 in my code instead of 1000000. VS understand 1e6 - it simply converts it to 1000000 when it tidies up the line - try it. – Basic Feb 08 '12 at 08:09
  • I can, of course, format it/output it any way I like before display to the user. This is purely to make my life easier – Basic Feb 08 '12 at 08:10
  • I've added a screenshot - not sure how much clearer I can make it – Basic Feb 08 '12 at 23:17
  • Dim whatIWant As String = "1e6" Dim whatIGet = Decimal.Parse(whatIWant, System.Globalization.NumberStyles.Float); – Jeremy Thompson Feb 08 '12 at 23:33
  • Thanks for trying to give me an alternative, but I wouldn't do that ever. It's hacky, prone to run-time errors (typos in number) and requires additional processing - All I want is to tweak the editor's auto-formatting, not change the fundamental code. – Basic Feb 09 '12 at 09:16
  • I wouldn't do it either - I'd use the QuickWatch window technique. You would think with the IDE switch from Winforms to WPF in 2010 would allow for these tweaks we want. Perhaps you could put a bounty on this question, but I don't think its possible and bounties I've put on the VS Extension questions came up blank and lost me points: http://stackoverflow.com/questions/7816556/visual-studio-extend-ide-the-exception-assistant – Jeremy Thompson Feb 09 '12 at 22:46
  • Whoops - I forgot to +91 your answer for a workaround. Sorry. Fixed now – Basic Feb 21 '12 at 14:23