Case 1: we can convert type by the following ways .....
First way
int someInt = 10;
double someDouble = (double) someInt;
Same thing in second way
int someInt = 10;
double someDouble = Convert.ToDouble(someInt);
Case 2: We can convert somethings into string by the following ways .......
First way
int someInt = 10;
string someString = someInt.ToString();
Second way
int someInt = 10;
string someString = someInt.ToString(CultureInfo.InvariantCulture);
Now my question is which one is good?? I am asking this question because ReSharper always gives me suggestion like 2nd way for both cases. I don't which one should I follow.
int.ToString() uses Culture.CurrentCulture as an argument (and so results can vary from computer to computer):as in:
someInt.ToString() == someInt.ToString(CultureInfo.CurrentCulture);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With