diff --git a/S7.Net/Types/Boolean.cs b/S7.Net/Types/Boolean.cs
index cfb52f8..f7bc83e 100644
--- a/S7.Net/Types/Boolean.cs
+++ b/S7.Net/Types/Boolean.cs
@@ -14,20 +14,51 @@
}
///
- /// Sets the value of a bit to 1 (true), given the address of the bit
+ /// Sets the value of a bit to 1 (true), given the address of the bit. Returns
+ /// a copy of the value with the bit set.
///
+ /// The input value to modify.
+ /// The index (zero based) of the bit to set.
+ /// The modified value with the bit at index set.
public static byte SetBit(byte value, int bit)
{
- return (byte)((value | (1 << bit)) & 0xFF);
+ SetBit(ref value, bit);
+
+ return value;
+ }
+
+ ///
+ /// Sets the value of a bit to 1 (true), given the address of the bit.
+ ///
+ /// The value to modify.
+ /// The index (zero based) of the bit to set.
+ public static void SetBit(ref byte value, int bit)
+ {
+ value = (byte) ((value | (1 << bit)) & 0xFF);
+ }
+
+ ///
+ /// Resets the value of a bit to 0 (false), given the address of the bit. Returns
+ /// a copy of the value with the bit cleared.
+ ///
+ /// The input value to modify.
+ /// The index (zero based) of the bit to clear.
+ /// The modified value with the bit at index cleared.
+ public static byte ClearBit(byte value, int bit)
+ {
+ ClearBit(ref value, bit);
+
+ return value;
}
///
/// Resets the value of a bit to 0 (false), given the address of the bit
///
- public static byte ClearBit(byte value, int bit)
+ /// The input value to modify.
+ /// The index (zero based) of the bit to clear.
+ public static void ClearBit(ref byte value, int bit)
{
- return (byte)((value & (~(1 << bit))) & 0xFF);
+ value = (byte) (value & ~(1 << bit) & 0xFF);
}
-
}
}