protected void Page_Load(object sender, EventArgs e) { Single s = 0.0241F; Literal1.Text = String.Format("{0:p}", s).Replace(" %","%"); }
Is there any other way to remove the space between the number and the % sign?
Just Curious.
I do not think so. If exists, please let me know.This works:
CultureInfo ci=CultureInfo.CurrentCulture.Clone()
as CultureInfo;System.Threading.Thread.CurrentThread.CurrentCulture=ci;
ci.NumberFormat.PercentNegativePattern=1;
ci.NumberFormat.PercentPositivePattern=1;
int x=5,y=-5;Response.Write(String.Format("{0:p} {1:p}",x,y));
Yeah work well. Can that be done in WebConfig?
This thread was great, both with the Replace and Culture methods! Thank you, both.
I would think you could set the culture when the web page loaded. Then in the Web.Config you could set the ci.NumberFormat.PercentPositivePattern=1.
0 comments:
Post a Comment