Use NumberFormatInfo to speed up Parsing techniques

By [)ia6l0 iii

Explicity specify the NumberFormatInfo on the parse method of the int class and speed up the Parse Performance.

Instead of ,

int temperature = GetTemperature(DateTime.Now);
string result = temperature.ToString();


NumberFormatInfo n = CultureInfo.InvariantCulture.NumberFormat;
int temperature = GetTemperature(DateTime.Now)
string result = temperature.ToString(n);

This ensures that you do not have to make calls to the current culture during the ToString invocations.

Use NumberFormatInfo to speed up Parsing techniques  (829 Views)