且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何将日期值与数字相乘

更新时间:2023-02-10 16:10:00

Difemeg写道:

total.text = date_dif.text * TxtQuantity.text ;

尝试这样的事情:

 total.text =( double  .Parse(date_dif.text)*  double  .Parse(TxtQuantity.text))。ToString(); 





祝你好运,

Edo uote>

试试这个与你需要的相似的例子:



 DateTime a =  new  DateTime( 2008  01  02  06  30  00 跨度>); 
DateTime b = new DateTime( 2008 01 03 06 30 00 );
TimeSpan持续时间= b - a;
String result = TimeSpan.FromTicks(duration.Ticks * 5 )。ToString();





希望这会有所帮助!


非常感谢它非常好用





 total.text =( double  .Parse (date_dif.text)*  double  .Parse(TxtQuantity.text))。ToString(); 





但是,要添加货币,如


can some one please help me out
I have a date value

date_dif.text = ((Convert.ToDateTime(date1.Text) - Convert.ToDateTime(date2.Text)).Days).ToString();

I want to multiply the difference with a figure from
example
total.text = date_dif.text * TxtQuantity.text;

when ever i do that it shows this error
Operator '*' cannot be applied to operands of type strings and strings Please how do i resolve the issue

thanks in advance

Difemeg wrote:

total.text = date_dif.text * TxtQuantity.text;

Try something like this:

total.text = (double.Parse(date_dif.text) * double.Parse(TxtQuantity.text)).ToString();



Good luck,
Edo


Try this example which is similar to what you needed :

DateTime a = new DateTime(2008, 01, 02, 06, 30, 00);
            DateTime b = new DateTime(2008, 01, 03, 06, 30, 00);
            TimeSpan duration = b - a;
            String result = TimeSpan.FromTicks(duration.Ticks * 5).ToString();



Hope this helps!


thank you very much It works perfectly well


total.text = (double.Parse(date_dif.text) * double.Parse(TxtQuantity.text)).ToString();



However, to add currency to it like