diff --git a/src/Humanizer/Bytes/ByteSize.cs b/src/Humanizer/Bytes/ByteSize.cs index cc45bcd88..0902440dd 100644 --- a/src/Humanizer/Bytes/ByteSize.cs +++ b/src/Humanizer/Bytes/ByteSize.cs @@ -330,9 +330,9 @@ public override bool Equals(object value) } ByteSize other; - if (value is ByteSize) + if (value is ByteSize size) { - other = (ByteSize)value; + other = size; } else { @@ -359,12 +359,12 @@ public int CompareTo(object obj) return 1; } - if (!(obj is ByteSize)) + if (obj is ByteSize size) { - throw new ArgumentException("Object is not a ByteSize"); + return CompareTo(size); } - return CompareTo((ByteSize)obj); + throw new ArgumentException("Object is not a ByteSize"); } public int CompareTo(ByteSize other)