<summary>/////</summary>/<param name= "FL" ></param>//&L T;returns></returns> private String convertfloattostring (float FL) {string str = string . Empty; str = String.Format ("{0:n2}", FL); return str; }///<summary>///String to Double//</summary>//<param name= "FL" ></para m>//<returns></returns> private Double convertstringtodouble (string fl) { Double str = 0.00; try {if (double. TryParse (fl, out str))//To output the correct data {} else { MessageBox.Show ("The data type is wrong, please check it!") "); }} catch (Exception ex) {ex. Message.tostring (); str = 0.00; } return str; } ///<summary>/////</summary>/<param name= "FL" ></param>//<re Turns></returns> private String convertdoubletostring (double fl) {string str = STRING.E Mpty; try {str = string. Format ("{0:c}", FL); } catch (Exception ex) {ex. Message.tostring (); str = "¥0.00"; } return str; }///<summary>//Tu Geovindu///</summary>/<param name= "FL" ></p aram>//<returns></returns> private string convertdecimaltostring (decimal fl) { String str = string. Empty; try {if (fl > 0) {str = string. Format ("¥{0:n2}", FL); } else {str = "¥0.00"; }} catch (Exception ex) {ex. Message.tostring (); str = "¥0.00"; } return str; }
Print format:
StringFormat format = new StringFormat (); Alignment Stringformatflags.directionrighttoleft //: Right-to-Zi text note format. FormatFlags = Stringformatflags.directionrighttoleft; Format. trimming = Stringtrimming.word; Format. Alignment =stringalignment.near; StringFormat FORMATC = new StringFormat (); Displayformatcontrol stringformatflags.measuretrailingspaces //Negative number format: right-aligned FORMATC. trimming = Stringtrimming.word; FORMATC. Alignment = Stringalignment.far; FORMATC. FormatFlags = Stringformatflags.nowrap | Stringformatflags.linelimit | Stringformatflags.noclip;
Csharp:double Convert to String