예제 #1
0
 // Binary operators
 [DebuggerStepThrough] public static Unit <T> operator +(Unit <T> lhs, Unit <T> rhs)
 {
     // Allow add to scalar zero
     if (rhs.IsScalarZero)
     {
         return(lhs);
     }
     if (lhs.IsScalarZero)
     {
         return(rhs);
     }
     if (lhs.UnitId != rhs.UnitId)
     {
         throw new Exception("Unit types don't match");
     }
     return(new Unit <T>(Operators <T> .Add(lhs.Value, rhs.Value), lhs.UnitId));
 }
예제 #2
0
 [DebuggerStepThrough] public static Unit <T> operator +(Unit <T> lhs, T rhs)
 {
     return(new Unit <T>(Operators <T> .Add(lhs.Value, rhs), lhs.UnitId));
 }