Skip to content

Commit 7eafae3

Browse files
author
ygorshkov
committed
* fix BaseDimensions.IsBaseQuantity implementation
1 parent 8ba3f9e commit 7eafae3

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

UnitsNet/BaseDimensions.cs

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,22 @@ public BaseDimensions(int length, int mass, int time, int current, int temperatu
3131
public bool IsBaseQuantity()
3232
{
3333
var dimensionsArray = new[] { Length, Mass, Time, Current, Temperature, Amount, LuminousIntensity };
34-
bool onlyOneEqualsOne = dimensionsArray.Where(dimension => dimension == 1).Take(2).Count() == 1;
34+
bool onlyOneEqualsOne = false;
35+
foreach (var dimension in dimensionsArray)
36+
{
37+
if (1 == dimension)
38+
{
39+
if (onlyOneEqualsOne)
40+
{
41+
return false;
42+
}
43+
onlyOneEqualsOne = true;
44+
}
45+
else if (0 != dimension)
46+
{
47+
return false;
48+
}
49+
}
3550
return onlyOneEqualsOne;
3651
}
3752

0 commit comments

Comments
 (0)