Basically, I am confuse with Developer devCopy = (Developer)dev.Clone();
Clone method of Developer class just creating a Employee clone, then how developer get another clone of developer.
public abstract class Employee
{
public abstract Employee Clone();
public string Name { get; set; }
public string Role { get; set; }
}
...
This might be a dumb question, but I don't get it:
I have a class called Card. I want to do a shallow clone using MemberWiseClone().
In Theory Card inherits from Object. So it should be able to use MemberWiseClone(), even if MWC() is protected ??
Am I missing/forgetting something?
...
I'm trying to implement an Undo/Redo stack in a C# application that I'm working on by restoring an Object to a previous state when undo is called. I have an 'Action' class which looks basically like this:
class Action
{
object old_state;
object new_state;
public Action(object old)
{
old_state = old;
}
p...
Hi All
I am using this.MemberwiseClone() to create shallowcopy but it is not working. Please look at the code below.
public class Customer
{
public int Id;
public string Name;
public Customer CreateShallowCopy()
{
return (Customer)this.MemberwiseClone();
}
}
class Program
{...