culture invariant object ToString()

The System.Convert class has a static ToString overload that takes an object.

Convert.ToString(obj, CultureInfo.InvariantCulture);

Based on my benchmarks, this is roughly twice as fast as string.Format(CultureInfo.InvariantCulture, "{0}", value) and, more importantly, it looks cleaner. However, if you are building a string already, I’d recommend FormattableString.Invariant.

FormattableString.Invariant($"Object value: {obj}")

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)