A common task for developers is to have to calculate tax for an item depending upon a total
price. This quick code example shows you how to convert from double to decimal data types and
perform a simple tax calculation.
<% @Page Language="C#" %>
<script runat="server">
public void Page_Load(Object sender, EventArgs e){
double SubTotal = 12.00;
double doublepretax = 0.00;
doublepretax = SubTotal * .07;
decimal pretax = new decimal(doublepretax);
pretax = Decimal.Round(pretax,2);
doublepretax = System.Convert.ToDouble(pretax);
Response.Write(doublepretax);
}
</script>
|