DicomObjects.NET.8.48 Documentation
DicomObjects Namespace / DicomDataSet Class / Clone Method / Clone() Method
Example

In This Topic
    Clone() Method
    In This Topic
    Returns a copy of the DicomDataSet
    Syntax
    'Declaration
     
    
    Public Overloads Overridable Function Clone() As System.Object
    public virtual System.object Clone()

    Return Value

    Remarks

    This method makes a Shallow Copy of the DicomDataSet

    A shallow copy will only have the top level objects replicated, any referenced objects under the top level will be shared by the original DicomDataSet and the cloned copy.

    Example
    // Load an original dataset from file
    DicomDataSet original = new DicomDataSet("Dataset.dcm");
                
    // Clone the dataset for safe modifications
    DicomDataSet cloned = original.Clone() as DicomDataSet;
                     
    // Example: Add a tag to the cloned dataset without affecting the original
    cloned.Add(Keyword.InstitutionName, "Temporary Testing Site");
                
    // Save the modified clone
    cloned.Save("ClonedModifiedDataset.dcm");
    Requirements

    Target Platforms: .NET CLR 4.8 or higher

    See Also