c# - How to format a string as currency without dollar sign

String format currency without dollar sign
string-format-currency-without-dollar-sign.aspx

<%@ Page Language="C#" AutoEventWireup="true"%>
<%@ Import Namespace="System.Globalization" %>  

<!DOCTYPE html>  
<script runat="server"> 
    protected void Button1_Click(object sender, System.EventArgs e)  
    {
        //this line create an int variable.
        int number = 234;

        CultureInfo gbCulture = new CultureInfo("en-GB");
        
        //this line create a decimal variable.
        decimal decimalValue = 236.86M;

        //this line create a double variable.
        double doubleValue = 555.153;

        Label1.Text = "Integer: " + number;
        Label1.Text += "<br />Decimal: " + decimalValue;
        Label1.Text += "<br />Double: " + doubleValue;

        Label1.Text += "<br /><br />string format currency without dollar sign..............";
        //format string using ToString method.
        Label1.Text += "<br />integer: " + number.ToString("N");
        Label1.Text += "<br />integer: " + number.ToString("N1");
        Label1.Text += "<br />decimal value: " + decimalValue.ToString("N2");
        Label1.Text += "<br />double value: " + doubleValue.ToString("N2");

        //format string using string.format method.
        Label1.Text += "<br /><br />format integer using string.format method: " + string.Format("{0:N}", number);
        Label1.Text += "<br />with [en-GB] culture: " + string.Format(gbCulture,"{0:C}", number);
    }  
</script>  
  
<html xmlns="http://www.w3.org/1999/xhtml">  
<head id="Head1" runat="server">  
    <title>c# example - string format currency without dollar sign</title>  
</head>  
<body>  
    <form id="form1" runat="server">  
    <div>  
        <h2 style="color:MidnightBlue; font-style:italic;">  
            c# example - string format currency without dollar sign
        </h2>  
        <hr width="550" align="left" color="Gainsboro" />  
        <asp:Label   
            ID="Label1"   
            runat="server"  
            Font-Size="Large"  
            >  
        </asp:Label>  
        <br /><br />
        <asp:Button   
            ID="Button1"   
            runat="server"   
            Text="string format currency without dollar sign"  
            OnClick="Button1_Click"
            Height="40"  
            Font-Bold="true"  
            />  
    </div>  
    </form>  
</body>  
</html>
More c# examples