c# - 'does not implement interface member 'System.ICloneable.Clone()' -
i'm having little issue calling in icloneable interface
i've told class want utilize interface such:
class unitclass: icloneable
and have placed in function cloning
public object clone() { homecoming this.memberwiseclone(); }
however reason programme telling me have not implemented system.icloneable.clone() tried giving function explicit name so...
public object system.icloneable.clone()
but little effect, know i'm doing wrong?
edit: total class
class unitclass: icloneable { //----------------------------------------------------------------------------------------------- //----------------------------------------------variables---------------------------------------- private int unitid; //added xml private string unitname; private int unitbasehp; private int unitcurrenthp; private carrier unitcarrier; private int unitrechargetime; private int turnlastplayed; private int strengthagainstfighters; private int strengthagainstbombers; private int strengthagainstturrets; private int strengthagainstcarriers; //----------------------------------------------------------------------------------------------- //---------------------------------------------constructor--------------------------------------- public unitclass() { unitid = 0; unitname = "name not set"; unitbasehp = 0; unitcurrenthp = 0; unitcarrier = null;//carrier works faction ie red/blue or left/right unitrechargetime = 0; turnlastplayed = 0; strengthagainstfighters = 0; strengthagainstbombers = 0; strengthagainstturrets = 0; strengthagainstcarriers = 0; } //----------------------------------------------------------------------------------------------- //---------------------------------------------gets , sets------------------------------------- public int unitid//public { set { unitid = value; } { homecoming unitid; } } public string unitname//public { set { unitname = value; } { homecoming unitname; } } public int unitbasehp//public { set { unitbasehp = value; } { homecoming unitbasehp; } } public int unitcurrenthp//public { set { unitcurrenthp = value; } { homecoming unitcurrenthp; } } public carrier unitcarrier//public { set { unitcarrier = value; } { homecoming unitcarrier; } } public int unitrechargetime//public { set { unitrechargetime = value; } { homecoming unitrechargetime; } } public int turnlastplayed//public { set { turnlastplayed = value; } { homecoming turnlastplayed; } } public int strengthagainstfighters//public { set { strengthagainstfighters = value; } { homecoming strengthagainstfighters; } } public int strengthagainstbombers//public { set { strengthagainstbombers = value; } { homecoming strengthagainstbombers; } } public int strengthagainstturrets//public { set { strengthagainstturrets = value; } { homecoming strengthagainstturrets; } } public int strengthagainstcarriers//public { set { strengthagainstcarriers = value; } { homecoming strengthagainstcarriers; } } //--------------------------------------------------------------------------- public object clone() { homecoming this.memberwiseclone(); } }
this built fine me.
public class myclone : icloneable { public object clone() { homecoming this.memberwiseclone(); } }
you don't perhaps want share more of class? nil jumping out @ me.
c# icloneable
No comments:
Post a Comment