I don’t think you can edit the value in TypedValue this way. You should instead, create a new TypedValue object to replace the old one. Get the Xdata from the entity, convert the Resultbuffer into a List<TypedValue>, replace the TypedValue, convert the List<TypedValue> back to a ResultBuffer, set the xdata with your new buffer.
Clear as mud?
To make things easier, do a search in this forum for TypedValueList. This class has implicit operators that help do these conversions