How to display a var in string format?

In the view,
PAYMENT1 = 1,200.50
PAYMENT2 = 1,500.50

totalpayment = 2701

I want the totalpayment to have the format with comma.

totalpayment= 2,701.00

I tried using .ToString but did'nt work. Any idea?

 public ActionResult Edit(int id, bool update = false) { TBL_PROJ project = db.TBL_PROJ.Find(id);  ViewBag.PAYMENT1 = Convert.ToDecimal(project.PAYMENT1).ToString("#,##0.00"); ViewBag.PAYMENT2 = Convert.ToDecimal(project.PAYMENT2).ToString("#,##0.00");  var  totalPayment = project.PAYMENT1 + project.PAYMENT2; project.TotalPayment = (float)Math.Round(totalPayment, 2); //This Part  return View(project); } 

Replay

Category: c# Time: 2016-07-29 Views: 0

Related post

iOS development

Android development

Python development

JAVA development

Development language

PHP development

Ruby development

search

Front-end development

Database

development tools

Open Platform

Javascript development

.NET development

cloud computing

server

Copyright (C) avrocks.com, All Rights Reserved.

processed in 0.220 (s). 12 q(s)