Basic
Basic

Reputation: 26766

Force Visual Studio to preserve exponent shorthand notation eg "1e6"

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

Upvotes: 2

Views: 509

Answers (1)

Jeremy Thompson
Jeremy Thompson

Reputation: 65682

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

Upvotes: 1

Related Questions