怎样有效重写C#中的Clone()
答案:1 悬赏:60
解决时间 2021-02-18 23:18
- 提问者网友:缘字诀
- 2021-02-18 09:30
怎样有效重写C#中的Clone()
最佳答案
- 二级知识专家网友:冷風如刀
- 2021-02-18 09:59
通常情况下是使用构造函数构造一个新的对象
如下
public override object Clone()
{
return new object();
}
ArrarList类
public override object Clone()
{
return new ArrarList(this);
}
/////////////
//补充
////////////
public class Teacher
{
public string Name;
public string age;
public object Clone()
{
Teacher t = new Teacher();
t.Name = this.Name;
t.age = this.age;
return t;
}
}
public class ExArrayList : ArrayList
{
public override object Clone()
{
return base.Clone();
}
}
=============================
没搞懂你什么意思
加我QQ 289771897给你详细解答
不知道你明白Clone的意思不
Clone就是创建一个目标的副本
如下
public override object Clone()
{
return new object();
}
ArrarList类
public override object Clone()
{
return new ArrarList(this);
}
/////////////
//补充
////////////
public class Teacher
{
public string Name;
public string age;
public object Clone()
{
Teacher t = new Teacher();
t.Name = this.Name;
t.age = this.age;
return t;
}
}
public class ExArrayList : ArrayList
{
public override object Clone()
{
return base.Clone();
}
}
=============================
没搞懂你什么意思
加我QQ 289771897给你详细解答
不知道你明白Clone的意思不
Clone就是创建一个目标的副本
我要举报
如以上问答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
推荐资讯
• 手机登qq时,显示手机磁盘不足,清理后重新登 |
• 刺客的套装怎么选啊? |