c# 4.0 - Decimal to Percentage formatter -


I am using this format {0: P2} returning this fair value But the problem is giving space between the value and the% symbol How do I remove that place?

Example:

  string format ("value: {0: P2}.", 0.8526) // format 85.26%  
< P> I want to remove the space between 85.26 and% symbols.

The formatting of one percent value is handled while formatting the value. To be more specific, the formatting controls and for you the value of that property leads to 0 <0> n% pattern but instead you want to use 1 code which results in the < Code> n% . In your case, because you do not specify CultureInfo or NumberFormatInfo while formatting the value, then you are using current culture for formatting (in Windows by user Established culture). You can make a clone of it and modify it:

  var cultureInfo = CultureInfo.CurrentCulture; Var number format = (Numberformat Info) cultural information. Number format.clone (); NumberFormat.PercentPositivePattern = 1; Var result = string.form (number format, "value: {0: P2}.", 0.8526);  

In order to formulate a negative number, you must modify it accordingly.


Comments

Popular posts from this blog

import - Python ImportError: No module named wmi -

Editing Python Class in Shell and SQLAlchemy -

c# - MySQL Parameterized Select Query joining tables issue -