Is it possible to get a warning if return value is not used?
问题 I have a extension method, which returns a value. In this case it should set a specific bit in an byte: public static byte SetBit(this byte b, int bitNumber, bool value) { if (value) { return (byte)(b | (1 << bitNumber)); } return (byte)(b & ~(1 << bitNumber)); } The returned value needs to be assigned to a variable again, because I can not combine this and ref : byte myByte = 3; myByte = myByte.SetBit(1, false); It is easy to forget the assignment by accident. Someone can think, the method