如何将时间跨度乘以百分比

问题描述

我正在尝试将TimeSpan与系数相乘,但是我不知道该怎么做。

我已经尝试过:

long ErrorCoef = 25;
TimeSpan TotalTimer = new TimeSpan(10,1,2,0);
TimeSpan TotalTimer2 = TimeSpan.FromTicks(TotalTimer.Ticks + TotalTimer.Ticks * (ErrorCoef / 100));

但是(ErrorCoef/100)自动转换为Long,因此它返回0。

(TimeSpan.FromTicks()方法仅接受Long而不接受Double)

解决方法

Timespan有一个Multiply方法,所以

    
        .flex-rows {
          display: flex;
          flex-direction: column;
        }
    
        .flex {
          display: flex;
        }
    
        .parent {
          height: 250px;
          width: 100%;
        }
    
        .child1,.child2,.child3 {
          float: left;
          display: inline-block;
          height: 100%;
          margin: 0px;
          padding: 0px;
        }
    
        .child1 {
          background-color: blue;
          width: calc(100% - 253px);
        }
    
        .child1>*,.child1>*>* {
          width: 100%;
          display: block;
          height: 100%;
        }
    
        .child2 {
          background-color: green;
          width: 100px;
        }
    
        .child3 {
          background-color: red;
          width: 150px;
        }
       .child1 textarea {
       overflow-y: scroll;
       }
    
    

应该可以解决问题。