I know to perform a shallow copy in C# we could use MemberwiseClone() function but I have an object inside a function and I want to take a copy of this object, so when I added to a list it won't refer to the same object when the object is changed here is my code
public void Do(object undoState)
{
_index += 1;
if (_buffer.Count > _index)
_buffer.RemoveRange(_index, _buffer.Count - _index);
_buffer.Add(undoState);
}
I want to copy the UndoState object to a new object and added to the buffer
thank you