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

2
  • please add a screenshot to show me before and after 'VS understand 1e6 - it simply converts it to 1000000 when it tidies up the line' Feb 8, 2012 at 22:51
  • +1 I added a comment, I think you can only do it using a string for "WhatUWant" Feb 8, 2012 at 23:35

1 Answer 1

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

7
  • 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 8, 2012 at 8: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 8, 2012 at 8:10
  • I've added a screenshot - not sure how much clearer I can make it
    – Basic
    Feb 8, 2012 at 23:17
  • Dim whatIWant As String = "1e6" Dim whatIGet = Decimal.Parse(whatIWant, System.Globalization.NumberStyles.Float); Feb 8, 2012 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 9, 2012 at 9:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.