In my class I have this property:
public decimal Percentage
开发者_JAVA技巧    {
        get;
        set;
    }
This value is displaying as a decimal. Something like this:
-0.0214444
I need to show it something like this:
-2.14444
How can I change to this format in my property?
Just multiply it by 100.
<%= myObject.Percentage * 100 %>
You can round it to a smaller number of decimal places:
<%= Math.Round(myObject.Percentage * 100, 3) %>
Another way:
<%= string.Format("Percentage is {0:0.0%}", myObject.Percentage) %>
You can use the "P" format string to add the percent sign. You can create another property to wrap it or just get Percentage and then call ToString.
public decimal Percentage { get; set; }
public string FormattedPercentage 
{ 
    get { return Percentage.ToString("P"); }
}
 
         
                                         
                                         
                                         
                                        ![Interactive visualization of a graph in python [closed]](https://www.devze.com/res/2023/04-10/09/92d32fe8c0d22fb96bd6f6e8b7d1f457.gif) 
                                         
                                         
                                         
                                         加载中,请稍侯......
 加载中,请稍侯......
      
精彩评论