Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

IFormatProvider with Integer value

I have an Integer value in my object. I need to cast it as an integer value. So I have done it this way. System.Convert.ToInt64(Object) But FxCop said that I need to provide with IFormatProvider. String data type I have no issue with provide IFormatProvider. How can I provide an IFormatProvider for integer value?

like image 815
Charitha Avatar asked Sep 16 '25 03:09

Charitha


1 Answers

It depends on how you need to print your value.

e.g. using:

var provider = System.Globalization.CultureInfo.InvariantCulture;

you will get a string that is independent from your local (regional) settings.

Using:

var provider = System.Globalization.CultureInfo.CurrentCulture;

or:

var provider = System.Globalization.CultureInfo.CurrentUICulture;

instead, the string will be printed using your local (regional) machine settings.

like image 165
digEmAll Avatar answered Sep 17 '25 18:09

digEmAll