In a particular project for a client I needed to copy all field properties from document A to document B. However the content type should not be changed. For simplicity I ignore edge cases. For example in case the source and destination content type have different required SPFields.
At first I copied all available fields from source to destination:
The content type changed. No wonder as the SPField ‘ContentType’ was copied.
Changed code to to ignore SPField ‘ContentType’
But still content type changed.
It turns out that you need to skip the SPField ‘ContentType’ and ‘MetaInfo’ to make sure the content type of the destination item is not changed.
Final code snippet: