ScanMaster.Profile.Clone C# (CSharp) Метод

Clone() публичный Метод

public Clone ( ) : object
Результат 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

Пример #1
0
 public Profile GetCloneOfCurrentProfile()
 {
     return((Profile)currentProfile.Clone());
 }