ScanMaster.Profile.Clone C# (CSharp) Method

Clone() public method

public Clone ( ) : object
return object
        public object Clone()
        {
            // Slightly odd way to clone an object: serialize it and deserialize straight away.
            MemoryStream m = new MemoryStream();
            BinaryFormatter bf = new BinaryFormatter();
            bf.Serialize(m,this);
            m.Position = 0;
            Profile newProfile = (Profile)bf.Deserialize(m);
            newProfile.Name += " copy";
            return newProfile;
        }

Usage Example

Example #1
0
 public Profile GetCloneOfCurrentProfile()
 {
     return((Profile)currentProfile.Clone());
 }