I have a byte array property that must be a certain length. I am tempted to put a check in the property's set
block that would throw an ArguementOutOfRange exception if the length is not correct.
private const int MY_ARRAY_LENGTH = 25;
private byte[] m_myArrray;
public byte[] MyArray
{
get
{
return m_myArray
}
set
{
if (value.Length != MY_ARRAY_LENGTH)
{
throw new ArgumentOutOfRange();
}
m_myArray = value;
}
Is that the best practice for this type of bounds checking?